判断键值

流过昼夜 提交于 2019-12-10 11:40:48

在之前开发一些硬件设备的时候,会有一些设备的物理按键不知道键值是什么,然后写了一个简单的测试方法。代码如下:


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

/// <summary>
///  得到输入
/// </summary>
public class GetKeyValue : MonoBehaviour
{
	private void Update ()
    {
        if (Input.anyKeyDown)
        {
            foreach (KeyCode keycode in Enum.GetValues(typeof(KeyCode)))
            {
                if (Input.GetKeyDown(keycode))
                {
                    Debug.Log("Current Key is : " + keycode.ToString());
                }
            }
        }	
	}
}

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!