查看按下的按键的值

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

public class KeyCodeDemo : MonoBehaviour {

    public Text text;
    void Update()
    {
        if (Input.anyKeyDown)
        {
            foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode)))
            {
                if (Input.GetKeyDown(keyCode))
                {
                    text.text = "Current Key is : " + keyCode.ToString();
                }
            }
        }


    }
}

 

posted @ 2020-08-11 16:22  哎呦不能错喔  阅读(102)  评论(0编辑  收藏  举报