I am implementing unity login screen in my android game. The problem is that when I click on the InputField, the keyboard opens in floating mode:
I attached the following method to the InputField:
public void onTouch()
{
TouchScreenKeyboard.hideInput = true;
TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
}
I've tried various variations of the overloaded Open method and keyboard types. It opened different types of keyboard, but didn't remove the floating mode.
Of course, I can manually disable this mode on the keyboard itself, and then it will always start up normally. But this problem is on all smartphones with Android 12 at the first start. And I would like the keyboard to start up normally right away.
Also, this line
TouchScreenKeyboard.hideInput = true;
should disable the keyboard's own input field. However, she does not. I looked at Android Logcat, and found out that after opening the keyboard, this field becomes False.
I know that I can implement my own keyboard inside Unity. And I will resort to this method if I don't find another solution.
How can I disable floating mode? And how can I disable the keyboard input field?
CodePudding user response:
I wrote almost same script as you, but everything is working fine, first thing that you mentioned is keyboard opening in floating mode.
Right now i did build android game and the same script as yours opening default keyboard attached to the bottom of screen(as it should be), probably it's your problem, maybe you changed it in phone settings or somewhere else, but still there's unnecessary input field, i managed to remove it after short delay, like this:
public void openAndroidKeyboard()
{
TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default);
Invoke("hideInputField", 0.1f);
}
private void hideInputField()
{
TouchScreenKeyboard.hideInput = true;
}
Not sure if this is the best way to disable it, but it works, you can try less delay to make it less noticable,