Forum Discussion
graves3d
7 years agoHonored Guest
Virtual Keyboard - Oculus GO
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.
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
Replies have been turned off for this discussion
- AnonymousEven I am Facing the same problem. the keyboard appears in the bottom and rotates with camera
- AnonymousAny answers regarding how to implement native android keyboard into Oculus GO App??
- AnonymousI 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.
- AnonymousI have submitted bug tickets with both Unity and Oculus for this issue.
https://fogbugz.unity3d.com/default.asp?1104565_autbjmsqtj0aqio7
https://developer.oculus.com/bugs/bug/708259166225395/ - emilien_degutExplorerI have the same issue @tkeene_vspatial : a green bar appear at the bottom of my Oculus GO. Have you solved your issu?
- riyarathi00Honored Guestplease give any solution I am facing same problem :(
- perceptimageryHonored 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. - yunhan0ExplorerHi @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@perceptimagery @yunhan0
I may have a solution to this problem involving overrides and reflection:using System.Reflection;
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.
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.UI/UI/Core/InputField.cs#lines-2252:2254
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.UI/UI/Core/InputField.cs#lines-773:865
}
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);
}
}
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 1 year ago