简体   繁体   中英

Numerical keyboard quickly closes and open between input fields on Unity

I have a mobile project where the user must type the confirmation code from a text message sent through cellphone. The number is made by 4 digits, so I decided to use 4 input fields that when finished editing concatenate the four fields and check if the resulted string is correct.

Currently the problem with this method is that either when the player types a number and the field focus automatically on the next one or when the player clicks on each of the input fields to edit a character, the keyboard automatically closes and reopen. It's very quickly but noticeable.

I've tried the following code on update with no success

if (currentScreen == 3) //Scene for code verification
    TouchScreenKeyboard.Open("", TouchScreenKeyboardType.NumberPad);

for some reason focusing on a new input field automatically forces the keyboard to closes, and as soon as I select the new input field, it reopens...

I'm using unity 5.6.1f1 and the error occurs on iOS and Android.

Thank you in advance for any help!

Found the answer for this problem here:

https://answers.unity.com/questions/1075452/ios-touchscreenkeyboard-closes-and-open-when-tappi.html

You could also use one input field and set maximum length to 4 and then get it as a string to use it later, it is better if you don't want to modify unity solution in the native iOS and Android codes.

Cheers!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM