10 [CustomEditor(typeof(XboxControllerInputSource))]
13 private SerializedProperty horizontalAxisProperty;
14 private SerializedProperty verticalAxisProperty;
15 private SerializedProperty submitButtonProperty;
16 private SerializedProperty cancelButtonProperty;
17 private SerializedProperty customMappingsProperty;
19 private static bool useCustomMapping;
21 private void OnEnable()
23 horizontalAxisProperty = serializedObject.FindProperty(
"horizontalAxis");
24 verticalAxisProperty = serializedObject.FindProperty(
"verticalAxis");
25 submitButtonProperty = serializedObject.FindProperty(
"submitButton");
26 cancelButtonProperty = serializedObject.FindProperty(
"cancelButton");
27 customMappingsProperty = serializedObject.FindProperty(
"mapping");
32 serializedObject.Update();
33 EditorGUILayout.Space();
35 EditorGUILayout.LabelField(
"Event System Overrides",
new GUIStyle(
"Label") { fontStyle = FontStyle.Bold });
37 EditorGUI.indentLevel++;
39 EditorGUILayout.PropertyField(horizontalAxisProperty);
40 EditorGUILayout.PropertyField(verticalAxisProperty);
41 EditorGUILayout.PropertyField(submitButtonProperty);
42 EditorGUILayout.PropertyField(cancelButtonProperty);
44 EditorGUI.indentLevel--;
45 EditorGUILayout.Space();
47 EditorGUI.BeginChangeCheck();
49 useCustomMapping = EditorGUILayout.Toggle(
"Use Custom Mapping", useCustomMapping);
51 if (EditorGUI.EndChangeCheck())
55 for (
int i = 0; i < customMappingsProperty.arraySize; i++)
57 customMappingsProperty.GetArrayElementAtIndex(i).FindPropertyRelative(
"Type").enumValueIndex = i;
58 customMappingsProperty.GetArrayElementAtIndex(i).FindPropertyRelative(
"Value").stringValue =
string.Empty;
64 ShowList(customMappingsProperty);
67 serializedObject.ApplyModifiedProperties();
70 private static void ShowList(SerializedProperty list)
72 EditorGUILayout.Space();
74 list.isExpanded =
true;
75 EditorGUI.indentLevel++;
77 for (
int i = 0; i < list.arraySize; i++)
79 EditorGUILayout.BeginHorizontal();
80 list.GetArrayElementAtIndex(i).FindPropertyRelative(
"Type").enumValueIndex = i;
82 list.GetArrayElementAtIndex(i).FindPropertyRelative(
"Value").stringValue =
83 EditorGUILayout.TextField(list.GetArrayElementAtIndex(i).FindPropertyRelative(
"Value").stringValue);
84 EditorGUILayout.EndHorizontal();
87 EditorGUI.indentLevel--;