Unity3D获取当前键盘按键及Unity3D鼠标、键盘的基本操作

来源:互联网 发布:淘宝好评返现短信模板 编辑:程序博客网 时间:2024/06/05 23:41

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

 

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());            }        }    }} 


 

0 0
原创粉丝点击