从触摸屏键盘获取按键



如何使用触摸屏键盘访问单个键?我试过了

if (Input.GetKey(KeyCode.A))
UIActions.DebugText("The A Key was pressed!!");

但它没有返回任何东西。此类可用的方法似乎很少。正确的方法是什么?

using UnityEngine;
public class FullKeyboardUserInput : MonoBehaviour
{
private TouchScreenKeyboard mobileKeys;
void Start()
{
mobileKeys = TouchScreenKeyboard.Open("", TouchScreenKeyboardType.Default, false, false, false, true);
}
private void Update()
{
if (mobileKeys != null && mobileKeys.done)
{
GameManager.CurrentDriftName = mobileKeys.text;
UIActions.DebugText(GameManager.CurrentDriftName);
UIActions.NumKeyboardView(GameManager.instance.NumKeyboardUserInputView);
Destroy(gameObject);
}
if (Input.GetKey(KeyCode.A))
{
UIActions.DebugText("The A Key was pressed!!");
}
if (mobileKeys != null && mobileKeys.wasCanceled)
{
Destroy(gameObject);
}
}
}

触摸键盘不是输入击键的一种方式,而是一种输入文本的方式 - 您可以随时使用 InputField

最新更新