使用InputField时隐藏虚拟键盘 [英] Hide Virtual keyboard when using InputField

查看:689
本文介绍了使用InputField时隐藏虚拟键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用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 3D中做到这一点?

How can I do that in Unity 3D?

推荐答案

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时隐藏虚拟键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆