OK, here’s one thing from the “what’s new in Unity 5”.
" ANDROID
Disabled hidden input keyboard.
"
The thing is that I relied on that feature. Most of the time during the game, keyboard will be opened. Now after this feature is gone, how can I bring it back and why was it dropped in the first place?
It seems broken. Just report it as a bug. It’s really annoying. It wasn’t working earlier when hide mobile input was enabled and now they completely ruined it.
So, the thing is that according to the Android spec soft keyboards are not required to send KeyEvents when keys are pressed. And if no KeyEvents are issued then there is no way for Unity to know which key was pressed. More and more keyboards are taking advantage of this and only works in conjunction with a text field. This is very bad for game applications but that is the reality. Essentially the only keyboards required to send KeyEvents are hardware keyboards.
If anyone knows of any workarounds or solutions to this problem please let us know.
If you are targeting a finite set of devices which you know support hidden input. What you can do is open the keyboard yourself by calling into java. It’s pretty easy to open a keyboard and if the keyboard is emitting KeyEvents it should work.
The java code for opening and closing a keyboard looks something like this:
InputMethodManager imm = context.getSystemService(Context.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // open keyboard
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // close keyboard
You can use the AndroidJava* classes to do this from a C# script. One thing though, since this is going to open a window it needs to be called on the UI thread. There is an example how to do that here AndroidJavaRunnable.
Okay. I get it now. But why did Hide Mobile Input worked before? Like you could still type in text to Input Field without the text box, although the delete key event didn’t work and there was no way to select the text.
At some point we will probably revisit this and try to make it work. But ever since we added support for hidden input field, it has been causing more harm than good
Alright! I’m satisfied with your answer. I am happy with the input text box since there’s at least a way to get the input.
One more question though. Can I change the texture of the input box and the ok button? Or hide the OK button?
So just to follow up on this hidden input on Android thing… is Unity still working on improvements or did we punt here?
I see the status on this ticket:
is “wont fix”.
I also see however that Yury mentioned just on Apr 14th that a patch is coming. The patch release that came out on Apr 15th didn’t resolve the issue for us (in 5.0.1p1) so I’m hoping this is still in process. Is that the case? Can we expect something in future patch to add support back for hidden input on Android? Any ETA at all?
Bitter, I’m trying to do a plugin to be able to get the keyboard, but I can’t get the text and behavior. Basically it’s a mess to try to get it to work with a plugin and the current system.
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // open keyboard
imm.toggleSoftInput(0, InputMethodManager.HIDE_IMPLICIT_ONLY); // close keyboard
Any ideas? I’m not able to get the entered text returned to the screen. I’m trying to create a wrapper around it to replace the standard TouchScreenKeyboard with no luck.
I’m using unity 5.3.1f1 and when check Hide Input Mobile and also add TouchScreenKeyboard.hideInput = true; and mainInputField.shouldHideMobileInput = true; , I still get input like that. Any solution to hide or replace inputfield with custom inputfield?
Note : I’m using UI Canvas InputField.