HKI Core
InputHandlerDrawers.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using UnityEditor;
3 
4 namespace HKI.Core.GameSystems.Input.Editor
5 {
9  [CustomPropertyDrawer(typeof(KeyToggleInputHandler))]
10  public class KeyToggleInputHandlerDrawer : PropertyDrawer
11  {
12  // OnGUI function
13  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
14  {
15  Rect keyCodePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
16  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
17 
18  EditorGUI.PropertyField(keyCodePropertyRect, property.FindPropertyRelative("KeyCode"), GUIContent.none);
19  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
20  }
21  }
22 
26  [CustomPropertyDrawer(typeof(KeyDownInputHandler))]
27  public class KeyDownInputHandlerDrawer : PropertyDrawer
28  {
29  // OnGUI function
30  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
31  {
32  Rect keyCodePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
33  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
34 
35  EditorGUI.PropertyField(keyCodePropertyRect, property.FindPropertyRelative("KeyCode"), GUIContent.none);
36  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
37  }
38  }
39 
43  [CustomPropertyDrawer(typeof(KeyUpInputHandler))]
44  public class KeyUpInputHandlerDrawer : PropertyDrawer
45  {
46  // OnGUI function
47  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
48  {
49  Rect keyCodePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
50  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
51 
52  EditorGUI.PropertyField(keyCodePropertyRect, property.FindPropertyRelative("KeyCode"), GUIContent.none);
53  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
54  }
55  }
56 
60  [CustomPropertyDrawer(typeof(KeyInputHandler))]
61  public class KeyInputHandlerDrawer : PropertyDrawer
62  {
63  // OnGUI function
64  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
65  {
66  Rect keyCodePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
67  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
68 
69  EditorGUI.PropertyField(keyCodePropertyRect, property.FindPropertyRelative("KeyCode"), GUIContent.none);
70  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
71  }
72  }
73 
77  [CustomPropertyDrawer(typeof(MousePositionInputHandler))]
78  public class MousePositionInputHandlerDrawer : PropertyDrawer
79  {
80  // OnGUI function
81  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
82  {
83  EditorGUI.PropertyField(position, property.FindPropertyRelative("Position"), GUIContent.none);
84  }
85  }
86 
90  [CustomPropertyDrawer(typeof(MouseButtonDownInputHandler))]
91  public class MouseButtonDownInputHandlerDrawer : PropertyDrawer
92  {
93  // OnGUI function
94  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
95  {
96  Rect mouseButtonIdPropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
97  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
98 
99  EditorGUI.PropertyField(mouseButtonIdPropertyRect, property.FindPropertyRelative("MouseButtonId"), GUIContent.none);
100  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
101  }
102  }
103 
107  [CustomPropertyDrawer(typeof(MouseButtonUpInputHandler))]
108  public class MouseButtonUpInputHandlerDrawer : PropertyDrawer
109  {
110  // OnGUI function
111  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
112  {
113  Rect mouseButtonIdPropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
114  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
115 
116  EditorGUI.PropertyField(mouseButtonIdPropertyRect, property.FindPropertyRelative("MouseButtonId"), GUIContent.none);
117  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
118  }
119  }
120 
124  [CustomPropertyDrawer(typeof(MouseButtonInputHandler))]
125  public class MouseButtonInputHandlerDrawer : PropertyDrawer
126  {
127  // OnGUI function
128  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
129  {
130  Rect mouseButtonIdPropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
131  Rect booleanValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
132 
133  EditorGUI.PropertyField(mouseButtonIdPropertyRect, property.FindPropertyRelative("MouseButtonId"), GUIContent.none);
134  EditorGUI.PropertyField(booleanValuePropertyRect, property.FindPropertyRelative("BooleanValue"), GUIContent.none);
135  }
136  }
137 
141  [CustomPropertyDrawer(typeof(AxisInputHandler))]
142  public class AxisInputHandlerDrawer : PropertyDrawer
143  {
144  // OnGUI function
145  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
146  {
147  Rect axisNamePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
148  Rect floatValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
149 
150  EditorGUI.PropertyField(axisNamePropertyRect, property.FindPropertyRelative("AxisName"), GUIContent.none);
151  EditorGUI.PropertyField(floatValuePropertyRect, property.FindPropertyRelative("FloatValue"), GUIContent.none);
152  }
153  }
154 
158  [CustomPropertyDrawer(typeof(AxisRawInputHandler))]
159  public class AxisRawInputHandlerDrawer : PropertyDrawer
160  {
161  // OnGUI function
162  public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
163  {
164  Rect axisNamePropertyRect = new Rect(position.x, position.y, (position.width - 2.0f) / 2.0f, position.height);
165  Rect floatValuePropertyRect = new Rect(position.x + (position.width / 2.0f) + 1.0f, position.y, (position.width - 2.0f) / 2.0f, position.height);
166 
167  EditorGUI.PropertyField(axisNamePropertyRect, property.FindPropertyRelative("AxisName"), GUIContent.none);
168  EditorGUI.PropertyField(floatValuePropertyRect, property.FindPropertyRelative("FloatValue"), GUIContent.none);
169  }
170  }
171 }
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Custom property drawer for the KeyToggleInputHandler class.
Custom property drawer for the MouseButtonDownInputHandler class.
Custom property drawer for the KeyInputHandler class.
Custom property drawer for the MouseButtonInputHandler class.
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Custom property drawer for the AxisRawInputHandler class.
Custom property drawer for the MousePositionInputHandler class.
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Custom property drawer for the KeyDownInputHandler class.
Custom property drawer for the KeyUpInputHandler class.
Custom property drawer for the AxisInputHandler class.
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
Custom property drawer for the MouseButtonUpInputHandler class.