【问题标题】:Getting hold of keys from TouchScreenKeyboard从 TouchScreenKeyboard 获取按键
【发布时间】:2018-11-24 11:25:26
【问题描述】:

如何使用 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);
        }
    }
}

【问题讨论】:

    标签: c# iphone unity3d keyboard


    【解决方案1】:

    触摸键盘并不是一种输入击键的方式,它是一种输入文本的方式 - 您始终可以使用 InputField

    【讨论】:

      猜你喜欢
      • 2015-10-31
      • 1970-01-01
      • 2016-03-13
      • 1970-01-01
      • 2012-07-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多