Android Keyboard does not show when pressing input field in unity?
Solution 1
When using the InputField
component, you do not need TouchScreenKeyboard.Open
to open the keyboard manually. Once the InputField
is clicked on, it will open itself. Remove the unnecessary TouchScreenKeyboard.Open
code.
I am connecting via USB to my laptop using Unity Remote 5 app.
That's the problem.
The InputField
component will only open the keyboard when you build and run the program on the device. Unity Remote 5 is only used to detect touch on the screen and read the sensors such as the GPS and accelerometer sensors while programming on the Editor. For features supported with Unity Remote 5 see this post.
Also, TouchScreenKeyboard.Open
will not work in the Editor too. You have to build and run it on the mobile device for it to work but TouchScreenKeyboard.Open
is not needed here. Just build the game and deploy it to your device and the keyboard should open when you click on the InputField.
Solution 2
No need to call TouchScreenKeyboard.Open() method. The native keyboard will not show up if you are running it in Unity Remote app. But it will show up on touching input field once you build and run the app from File > Build Settings > Build or File > Build and Run.
Solution 3
you need the Cross-Platform-Input
asset from the Unity standard asset
pack in the asset store. this is free, and once imported into your project will work on its own with the text field. just import it and try you phone again
then you wont need:
if (input)
{
TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true);
}
input.keyboardType = TouchScreenKeyboardType.NumberPad;
Unitys mobile class will just open the keyboard when you tap the field. no extra coding needed.
Related videos on Youtube
Ak Pasaf
Updated on June 04, 2022Comments
-
Ak Pasaf almost 2 years
I have a simple scene in unity which has an input field in it. When I run my scene in my Android Device and press the input field, the android keyboard does not show. I am connecting via USB to my laptop using Unity Remote 5 app.
Here is my code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using TMPro; public class InputNumber : MonoBehaviour { public InputField input; // Use this for initialization void Start () { if (input) { TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, true); } input.keyboardType = TouchScreenKeyboardType.NumberPad; } // Update is called once per frame void Update () { } }
-
Arahasya over 5 yearsfirst use getComponent for InputField
-
Ak Pasaf over 5 yearsinput = this.GetComponent<InputField>(); I used this code in the start method but it didnot work
-
-
Ak Pasaf over 5 yearsI downloaded Standard asset and removed my code. However, when I run on my android phone, the android keyboard does not show when i click on the input field. Do i need to add sprites from cross-platformInput?
-
Daniel over 3 yearsUpvoted for stating that the damn keyboard wouldn't appear in Unity Remote. Took me an hour to find out.