cancel
Showing results for 
Search instead for 
Did you mean: 

Virtual Keyboard - Oculus GO

graves3d
Honored Guest
Hello!

We are implementing a virtual keyboard for the oculus go using Unity's Native UI system (UGUI). We've modified OVRInputModule to support the Oculus GO controller and we are able to interact with UGUI elements.
 Our problem is, whenever you click an input field it shows a native android input field, which in VR, looks like a white bar at the bottom of the user's view.

What is the recommended approach on how to 1) not have the native android input field show up,  and 2) have the input field behave as it would in a desktop VR application.

13 REPLIES 13

Anonymous
Not applicable
Even I am Facing the same problem. the keyboard appears in the bottom and rotates  with camera

Anonymous
Not applicable
Any answers regarding how to implement native android keyboard into Oculus GO App??

Anonymous
Not applicable
I am having this issue as well. Using Unity's input fields with the Curved UI plugin. A white or green bar appears at the bottom of the headset's field of view (press the headset closer to your face to get a good look at it) whenever an input field has focus. This occurs even if the Hide Mobile Input box is checked.

Anonymous
Not applicable

emilien_degut
Explorer
I have the same issue @tkeene_vspatial : a green bar appear at the bottom of my Oculus GO. Have you solved your issu?
 

riyarathi00
Honored Guest
please give any solution I am facing same problem  😞

perceptimagery
Honored Guest

yunhan0 said:

I solved this issue by writing a class inherits from the input field. So remove the default InputField component and attach the MobileInput. Don't forget to assign some properties such as TextComponent and Placeholder inside the new MobileInput Component.
using UnityEngine;
using UnityEngine.UI;

public class MobileInput : InputField
{
protected override void Start()
{
keyboardType = (TouchScreenKeyboardType)(-1);
base.Start();
}
}




hi @yunhan0
If you remove the Touch screen keyboard (obviously as there is no screen), what do you use along with the new MobileInput class to type? Do you use any specific VR keyboard? I am trying to find one that'd work with Oculus Go.

yunhan0
Explorer
Hi @perceptimagery ,
The solution I provided above is not working. I've dived into the input field source code and can confirm that without assigning a touch screen keyboard, the input field won't behave well, such as missing caret.
Eventually solved this problem by using VRUIKit's customised input field.

Anonymous
Not applicable
@perceptimagery  @yunhan0
I may have a solution to this problem involving overrides and reflection:
using System.Reflection;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class GoInputField : InputField {

private void ActivateInputFieldInternal() {
if (EventSystem.current == null)
return;

if (EventSystem.current.currentSelectedGameObject != gameObject)
EventSystem.current.SetSelectedGameObject(gameObject);
if (TouchScreenKeyboard.isSupported) {
if (GetBaseInput().touchSupported) {
TouchScreenKeyboard.hideInput = shouldHideMobileInput;
}
// Here is where the touchscreen keyboard is opened - we exclude
// the calls to TouchScreenKeyboard.Open()
// https://bitbucket.org/Unity-Technologies/ui/src/9f418c4767c47d0c71f1727eb42a9a9024e9ecc0/UnityEngine...
MoveTextEnd(false);
} else {
GetBaseInput().imeCompositionMode = IMECompositionMode.On;
OnFocus();
}
SetField("m_AllowInput", true);
SetField("m_OriginalText", text);
SetField("m_WasCanceled", false);
CallMethod("SetCaretVisible");
UpdateLabel();
}

protected override void LateUpdate() {
bool _m_ShouldActivateNextUpdate = GetField("m_ShouldActivateNextUpdate");

if (_m_ShouldActivateNextUpdate) {
if (!isFocused) {
ActivateInputFieldInternal();
SetField("m_ShouldActivateNextUpdate", false);
return;
}
SetField("m_ShouldActivateNextUpdate", false);
}

// Here this method usually handles all the TouchScreenKeyboard checks and
// deselets the InputField if the keyboard is not visible - lets not do that.
// https://bitbucket.org/Unity-Technologies/ui/src/9f418c4767c47d0c71f1727eb42a9a9024e9ecc0/UnityEngine...
}

BaseInput GetBaseInput() {
// Shim this method rather than use reflection, we have access to the EventSystem anyway.
if (EventSystem.current && EventSystem.current.currentInputModule)
return EventSystem.current.currentInputModule.input;
return null;
}

private BindingFlags flags = BindingFlags.NonPublic | BindingFlags.Instance;

void SetField(string name, T value) {
GetType().BaseType.GetField(name, flags).SetValue(this, value);
}

T GetField(string name) {
return (T)GetType().BaseType.GetField(name, flags).GetValue(this);
}

public void CallMethod(string name) {
GetType().BaseType.GetMethod(name, flags).Invoke(this, null);
}
}
There are obvious flaws in this approach - its not really reliable to expect this to work with other versions of Unity other than the version I'm using - 2018.2.X. Thankfully the Unity UI is open source so using the links included in the comments above you could convert this to another version without too much hassle. I hope this helps some others too and maybe unity could implement a fix too. I will point them to this implementation however and who knows, we could see a fix.