问题描述
我知道如何使用InputMethodManager
隐藏或显示虚拟键盘.
I know how to hide or display Virtual Keyboard using InputMethodManager
.
但是我想使用物理键盘在EditText
中输入文本,但是我不想在Unity 3D Android中显示虚拟键盘.
But I want to enter text in EditText
using Physical keyboard but I don't want to display Virtual Keyboard in Unity 3D Android.
推荐答案
Unity中没有EditText
这样的东西. InputField
用于接收来自设备的输入.
There is no such thing as EditText
in Unity. InputField
is used to receive input from a device.
您可以在Android上使用InputField
禁用虚拟关键字.不知道这是否适用于其他平台.
You can disable Virtual Keyword with InputField
on Android. Not sure if this will work for other platforms.
您的InputField:
Your InputField:
public InputField inputField;
禁用虚拟键盘:
inputField.keyboardType = (TouchScreenKeyboardType)(-1);
启用虚拟键盘:
inputField.keyboardType = TouchScreenKeyboardType.Default;
如果遇到奇怪的问题,请考虑从InputField
派生脚本,然后禁用虚拟键盘,最后,调用InputField
的基本Start
函数:
If you run into weird issues, consider deriving your script from InputField
, then disable Virtual Keyboard and finally, call the base Start
function of the InputField
:
public class HideVirtualKeyboard : InputField
{
protected override void Start()
{
keyboardType = (TouchScreenKeyboardType)(-1);
base.Start();
}
}
这篇关于使用InputField时隐藏虚拟键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!