HKI Core
InputSystemEditor.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using UnityEditor;
3 using HKI.Core.Editor.Misc;
4 
5 namespace HKI.Core.GameSystems.Input.Editor
6 {
10  [CustomEditor(typeof(InputSystem))]
11  public class InputSystemEditor : UnityEditor.Editor
12  {
13  // Private variables
14  SerializedProperty initInfoTextLocalizationSP = null;
15  SerializedProperty initErrorInfoTextLocalizationSP = null;
16 
17  SerializedProperty mousePositionInputHandlerSP = null;
18 
19  StandardReorderableList keyToggleInputHandlersRL = null;
20  StandardReorderableList keyDownInputHandlersRL = null;
21  StandardReorderableList keyUpInputHandlersRL = null;
22  StandardReorderableList keyInputHandlersRL = null;
23 
24  StandardReorderableList mouseButtonDownInputHandlersRL = null;
25  StandardReorderableList mouseButtonUpInputHandlersRL = null;
26  StandardReorderableList mouseButtonInputHandlersRL = null;
27 
28  StandardReorderableList axisInputHandlersRL = null;
29  StandardReorderableList axisRawInputHandlersRL = null;
30 
31  // OnEnable
32  void OnEnable()
33  {
34  initInfoTextLocalizationSP = serializedObject.FindProperty("InitInfoTextLocalization");
35  initErrorInfoTextLocalizationSP = serializedObject.FindProperty("InitErrorInfoTextLocalization");
36 
37  mousePositionInputHandlerSP = serializedObject.FindProperty("MousePositionInputHandler");
38 
39  keyToggleInputHandlersRL = new StandardReorderableList(serializedObject, "KeyToggleInputHandlers", "Key Toggle Input Handlers", false);
40  keyDownInputHandlersRL = new StandardReorderableList(serializedObject, "KeyDownInputHandlers", "Key Down Input Handlers", false);
41  keyUpInputHandlersRL = new StandardReorderableList(serializedObject, "KeyUpInputHandlers", "Key Up Input Handlers", false);
42  keyInputHandlersRL = new StandardReorderableList(serializedObject, "KeyInputHandlers", "Key Input Handlers", false);
43 
44  mouseButtonDownInputHandlersRL = new StandardReorderableList(serializedObject, "MouseButtonDownInputHandlers", "Mouse Button Down Input Handlers", false);
45  mouseButtonUpInputHandlersRL = new StandardReorderableList(serializedObject, "MouseButtonUpInputHandlers", "Mouse Button Up Input Handlers", false);
46  mouseButtonInputHandlersRL = new StandardReorderableList(serializedObject, "MouseButtonInputHandlers", "Mouse Button Input Handlers", false);
47 
48  axisInputHandlersRL = new StandardReorderableList(serializedObject, "AxisInputHandlers", "Axis Input Handlers", false);
49  axisRawInputHandlersRL = new StandardReorderableList(serializedObject, "AxisRawInputHandlers", "Axis Raw Input Handlers", false);
50  }
51 
52  // OnInspectorGUI function
53  public override void OnInspectorGUI()
54  {
55  serializedObject.Update();
56 
57  EditorGUILayout.LabelField("Game System Settings:", EditorStyles.boldLabel);
58  EditorGUILayout.PropertyField(initInfoTextLocalizationSP);
59  EditorGUILayout.PropertyField(initErrorInfoTextLocalizationSP);
60  EditorGUILayout.Space();
61 
62  EditorGUILayout.LabelField("Keyboard Input:", EditorStyles.boldLabel);
63  keyToggleInputHandlersRL.DoLayoutList();
64  keyDownInputHandlersRL.DoLayoutList();
65  keyUpInputHandlersRL.DoLayoutList();
66  keyInputHandlersRL.DoLayoutList();
67  EditorGUILayout.Space();
68 
69  EditorGUILayout.LabelField("Mouse Input:", EditorStyles.boldLabel);
70  EditorGUILayout.BeginHorizontal();
71  EditorGUILayout.LabelField("Mouse Position Input Handler");
72  EditorGUILayout.PropertyField(mousePositionInputHandlerSP);
73  EditorGUILayout.EndHorizontal();
74  EditorGUILayout.Space();
75  mouseButtonDownInputHandlersRL.DoLayoutList();
76  mouseButtonUpInputHandlersRL.DoLayoutList();
77  mouseButtonInputHandlersRL.DoLayoutList();
78  EditorGUILayout.Space();
79 
80  EditorGUILayout.LabelField("Axis Input:", EditorStyles.boldLabel);
81  axisInputHandlersRL.DoLayoutList();
82  axisRawInputHandlersRL.DoLayoutList();
83 
84  serializedObject.ApplyModifiedProperties();
85  }
86  }
87 }
This class provides you with a better handling of ReorderableList so that ReorderableLists can be use...
Custom inspector for the InputSystem class.