c# - 从 TouchScreenKeyboard 获取按键
问题描述
如何使用 TouchScreenKeyboard 访问单个按键?我试过了
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
推荐阅读
- android - 如何使卡片视图消失?
- angular - ng build 和 ng build --watch 之间的捆绑输出不一致
- postgresql - 在主机上的客户端 docker 和 postgres 服务器之间连接
- node.js - 两个公共子网无法与私有 ip 通信
- linear-programming - 使用 Google OR-Tools 对市场进行建模
- angularjs - 我收到一个错误错误:[$injector:unpr] 未知提供者:$resourceProvider <- $resource <- productResource
- bash - 仅当其他进程不使用时才清理文件
- html - 如何定位具有 position:fixed 的 NAV;在中心?
- excel - Excel VBA 数据抓取 - 并非所有数据都被提取
- list - 如何将元组列表拆分为列表元组?