首页 > 学院 > 开发设计 > 正文

Unity3D获取当前键盘按键

2019-11-14 13:47:23
字体:
来源:转载
供稿:网友

获取当前键盘按键,代码如下:

using UnityEngine;using System.Collections;public class GetCurrentKey : MonoBehaviour {    KeyCode currentKey;    void Start ()    {        currentKey = KeyCode.Space;    }        void OnGUI()    {        if (Input.anyKeyDown)        {            Event e = Event.current;            if (e.isKey)            {                currentKey = e.keyCode;                Debug.Log("Current Key is : " + currentKey.ToString());            }        }    }}

 


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表