简体   繁体   English

数字键盘在Unity的输入字段之间快速关闭和打开

[英]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. 该数字由4位数字组成,所以我决定使用4个输入字段,这些字段在完成编辑后将这四个字段连接起来,并检查结果字符串是否正确。

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. 我正在使用Unity 5.6.1f1,并且在iOS和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 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. 您也可以使用一个输入字段并将最大长度设置为4,然后将其作为字符串获取以供以后使用,如果不想在本机iOS和Android代码中修改统一解决方案,则更好。

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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