检测输入事件

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;

public class test : MonoBehaviour {

    public Text console;

    // Update is called once per frame
    void Update()
    {
        if (Input.anyKeyDown)
        {
            foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode)))
            {
                if (Input.GetKeyDown(keyCode))
                {
                    console.text = "Current Key is : " + keyCode.ToString();
                }
            }
        }
    }
}

你可能感兴趣的:(unity)