Search code examples
unity-game-enginehololensmrtk

MRTK - can't get the value from UI_KeyboardInputField object


Hello i am using the MRTK 2.7.3 and I am trying the read the value from a UI_KeyboardInputField object but seems something is wrong on my code

using Microsoft.MixedReality.Toolkit.Experimental.UI;

public void onSubmit()
{
    GameObject username = GameObject.Find("Username");
    UI_KeyboardInputField inputUsername = username.GetComponent<UI_KeyboardInputField>();
    Debug.Log("username" + inputUsername.Text); <<<ERROR
}

'UI_KeyboardInputField' does not contain a definition for 'Text' and no accessible extension method 'Text' accepting a first argument of type 'UI_KeyboardInputField' could be found (are you missing a using directive or an assembly reference?)

Maybe my approach is wrong how can i get the text value from this field ?

thanks


Solution

  • From UI_KeyboardInputField

    Only used in Unity 2018.4. No longer used in Unity 2019.3 and later versions (becomes an empty MonoBehaviour and is only around for compatibility) and you can safely remove it if you wish

    And also

    A component that can be added to InputField to make it work with Windows Mixed Reality's system keyboard.

    Sounds to me like this is/was only a helper component for forwarding the virtual keyboard input and the actual thing is all happening in a usual InputField component attached to the same GameObject and you rather want to access the .text of that one.