Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Virtual Keyboard - Oculus GO

graves3dgraves3d Posts: 5
NerveGear
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.

Comments

  • rohal_chandrakarrohal_chandrakar Posts: 2
    NerveGear
    Even I am Facing the same problem. the keyboard appears in the bottom and rotates  with camera
  • wilk3nswilk3ns Posts: 1
    NerveGear
    Any answers regarding how to implement native android keyboard into Oculus GO App??
  • tkeene_vspatialtkeene_vspatial Posts: 10
    NerveGear
    edited November 2018
    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.
  • emilien.degutemilien.degut Posts: 8 Oculus Start Member
    I have the same issue @tkeene_vspatial : a green bar appear at the bottom of my Oculus GO. Have you solved your issu?
     
  • riyarathi00riyarathi00 Posts: 1
    NerveGear
    please give any solution I am facing same problem  :(
  • perceptimageryperceptimagery Posts: 2
    NerveGear
    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.
  • yunhan0yunhan0 Posts: 7
    NerveGear
    edited June 2
    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.
  • shane_harrisshane_harris Posts: 2 Oculus Start Member
    edited April 8
    @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.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);
        }
    }
    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.

  • cavin12cavin12 Posts: 1
    NerveGear
    it was nice to see these kind of tips which help seo
  • yunhan0yunhan0 Posts: 7
    NerveGear
    @shane_harris
    Thanks for sharing, I'll try!
  • jones510jones510 Posts: 1
    NerveGear
    nice to see the updates train status
  • ben600ben600 Posts: 1
    NerveGear
    wilk3ns said:
    Any answers regarding how to implement native android keyboard into Oculus GO App??
    When you were looking to buy Sports Cars for your kids or else some Premium Cars then buying it from  is a great option or Choice. The Site sells Ride On Toys and Cars to the Local People all around the Australia
Sign In or Register to comment.