- Home /
World space InputField not behaving user friendly on Android
I have a problem with input fields in world space. specifically in combination with Android. When I click in the input field to open the on-screen keyboard, it often closes instantly. When clicking the input field again it also sometimes shows the keyboard and then instantly close it again. and it pops up the buttons at the bottom of android that are used a home and back button etc.
Interactable is turned off and when you click the field, it is turned on, we are doing this to build support for both Android and GearVR. When tapping the screen(or the side button at the GearVR) it does a Raycast on a collision box which matches the size & location of the button/inputfield/dropdown, it triggers Select() and Invoke() on the buttons. In the case of an input field it triggers Select() and ActivateInputField() However if you're casually handling the mobile device it seems that the input field is losing focus and closes, even before your fingers move over to the keyboard to start typing. Only when handling the device extremely carefully, it works. Looking away still causes the input field to lose focus and close the keyboard. The only other Select() method is called when a raycast succesfully hits a button.
Does anyone know a solution for this problem? I would love it to be user friendly and simply staying open until you press done/ok on the on-screen keyboard. Can I disable the keyboard from closing when losing focus? Is there an other method or event to trigger when handling InputFields in order for it to work properly?
Answer by remy_rm · Jul 11, 2018 at 12:31 PM
you could make your own input type, using a button and a normal text component.
I made a little script that will open the touchscreen keyboard and update the textfield with whatever is typed on the keyboard.
public Text nameField;
public Text placeHolder;
private bool openKeyBoard;
public void OpenKeyBoard()
{
keyboard = TouchScreenKeyboard.Open(nameField.text);
}
private TouchScreenKeyboard keyboard;
private void OnGUI()
{
if (!nameField.text.Equals(""))
{
placeHolder.enabled = false;
}
else
{
placeHolder.enabled = true;
}
if (keyboard != null)
{
nameField.text = keyboard.text;
}
if (keyboard.active == false)
{
openKeyBoard = false;
keyboard = null;
}
}
Your answer

Follow this Question
Related Questions
If i have a script how to I input an int from there to a text UI? 1 Answer
Keep input field caret active when focused on mobile devices in addition to native input field caret 0 Answers
Send inputfield entries via email 2 Answers
Unity inputfield crashes android app after entering too many letters 1 Answer
Disabling the inputfield above the keyboard or disable it all 0 Answers