*
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
public class InputDebug : MonoBehaviour {
|
||||
private List<KeyCode> pressedKeys = new List<KeyCode>();
|
||||
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
void OnGUI(){
|
||||
var values = Enum.GetValues(typeof(KeyCode));
|
||||
float h = 20;
|
||||
int rowid = 0;
|
||||
int columnId = 0;
|
||||
float columnWidth = 120;
|
||||
|
||||
int yOffset = 60;
|
||||
int maxRowCount = (Camera.main.pixelHeight - yOffset) / (int)h;
|
||||
|
||||
pressedKeys.Clear();
|
||||
|
||||
foreach(KeyCode key in values){
|
||||
if(Input.GetKey(key)){
|
||||
pressedKeys.Add(key);
|
||||
}
|
||||
|
||||
/*GUI.Label(new Rect( columnWidth * columnId ,yOffset + rowid * h, columnWidth, h),key.ToString());
|
||||
rowid++;
|
||||
if(rowid == maxRowCount){
|
||||
rowid = 0;
|
||||
columnId++;
|
||||
}*/
|
||||
}
|
||||
|
||||
string pressedString = "";
|
||||
foreach(var k in pressedKeys){
|
||||
pressedString += k.ToString() + " ";
|
||||
}
|
||||
|
||||
GUI.Label(new Rect( 10,10,400,30), string.Format("Keys pressed [{0}]: {1}", pressedKeys.Count, pressedString));
|
||||
|
||||
//Input.GetKey(KeyCode
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user