Unity任意按键检测并输出键值

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class PressKeyCheckScript : MonoBehaviour {
 5 
 6     // Use this for initialization
 7     void Start () {
 8     
 9     }
10     
11     // Update is called once per frame
12     void Update () {
13     
14     }
15     void OnGUI(){
16         Event a = Event.current;
17         if(a.isKey)
18             Debug.Log("press: "+ a.keyCode);
19     }
20 }

 

posted @ 2016-06-17 11:45  Haleclipse  阅读(1066)  评论(0编辑  收藏  举报