51 lines
899 B
C#
51 lines
899 B
C#
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections;
|
|
|
|
public class JoystickView : MonoBehaviour {
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
}
|
|
|
|
void OnGUI(){
|
|
DoGui ();
|
|
}
|
|
|
|
void DoGui(){
|
|
var joysticks = Input.GetJoystickNames ();
|
|
|
|
#if UNITY_EDITOR
|
|
Handles.BeginGUI ();
|
|
#endif
|
|
|
|
float height = 20;
|
|
for (int i = 0; i < 7; ++i) {
|
|
GUI.Label(new Rect(10,i * height + 10, 300,height), string.Format("Axis {0}: {1}", i, Input.GetAxis("Axis" + i)));
|
|
}
|
|
|
|
for (int i = 0; i < 20; ++i) {
|
|
GUI.Label(new Rect(410,i * height + 10, 300,height), string.Format("Button {0}: {1}", i, Input.GetKey (KeyCode.Joystick1Button0 + i)));
|
|
}
|
|
|
|
|
|
/*foreach(var j in joysticks){
|
|
|
|
//EditorGUILayout.TextField(j);
|
|
}*/
|
|
#if UNITY_EDITOR
|
|
Handles.EndGUI ();
|
|
#endif
|
|
}
|
|
|
|
void OnDrawGizmos(){
|
|
DoGui ();
|
|
}
|
|
}
|