Text Inputs from Mobile Keyboard

Hello everyone. I have an issue about mobile game. It is a word puzzle game and I need to input values.

This is a screen shot from gameplay. You can see that there are 4 different input fields. I hold them in a list and i go all of them. So the game works perfect on unity. However, on phone i cannot get keyboard text and put them to the input fields. How can i do this? If anybody can help i can give all informations about code and unity project structure. Please help i feel so desperated…

Since I’m uncertain exactly how you have things set up, I’ll just give some general information and hope it helps your case.

In the case of the Unity UI system (canvasses), you need to use an InputField element to process user input. Put this in the canvas, and then it should pop up with the keyboard when the attached Text component area is tapped, allowing the user to write in that text area. If this isn’t working, then perhaps there’s no EventSystem in the scene, or the Text components are covered by UI that you can’t see, or the specific Text component isn’t being correctly referenced in the InputField component, to trigger the keyboard event.

A suggestion: even if you don’t need to reference a specific Text component, because for instance the user input display is broken up into 4+ different Text components (as yours appears to be?), or maybe not rendered with Text components at all (because they’re rendered with sprites, or you want user input with no visible output on the canvas), I believe that you can still use the InputField effectively by referencing a disabled Text component and then manually calling inputField.ActivateInputField in OnEnable in a MonoBehaviour for the canvas it’s in. That should bring up the on-screen keyboard and let you enter text. You can then validate the input, output the text to different Text components on the screen (if you need to), etc, by using the built-in events for onValueChanged, onValidateInput, and onEditEnd. This seems like it could be far more effective than tying an InputField to a specific Text component, and it may solve your problem by ensuring that the keyboard is brought up exactly when you need it.

You can also just implement your own solution using TouchScreenKeyboard.Open, since that’s what’s used internally by the InputField anyways.

1 Like

Thanks a lot it was very helpful :slight_smile: