public override void OnInspectorGUI() { if (UdonSharpGUI.DrawDefaultUdonSharpBehaviourHeader(target)) { return; } serializedObject.Update(); var property = serializedObject.GetIterator(); property.NextVisible(true); while (property.NextVisible(false)) { switch (property.name) { case nameof(TouchSwitch.eventName): case nameof(TouchSwitch.onKnobRight): case nameof(TouchSwitch.onKnobLeft): URCUtility.UdonPublicEventField(serializedObject.FindProperty(nameof(TouchSwitch.eventTarget)), property); break; default: EditorGUILayout.PropertyField(property); break; } } serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { if (UdonSharpGUI.DrawDefaultUdonSharpBehaviourHeader(target)) { return; } serializedObject.Update(); var keyCodes = serializedObject.FindProperty(nameof(KeyboardInput.keyCodes)); var holds = serializedObject.FindProperty(nameof(KeyboardInput.holds)); var eventTargets = serializedObject.FindProperty(nameof(KeyboardInput.eventTargets)); var onKeyDownEvents = serializedObject.FindProperty(nameof(KeyboardInput.onKeyDownEvents)); holds.arraySize = keyCodes.arraySize; eventTargets.arraySize = keyCodes.arraySize; onKeyDownEvents.arraySize = keyCodes.arraySize; EditorGUILayout.PropertyField(keyCodes, new GUIContent("Key Mapping"), false); if (keyCodes.isExpanded) { for (var i = 0; i < keyCodes.arraySize; i++) { using (new EditorGUILayout.HorizontalScope()) { var keyCode = keyCodes.GetArrayElementAtIndex(i); var hold = holds.GetArrayElementAtIndex(i); keyCode.intValue = (int)(KeyCode)EditorGUILayout.EnumPopup((Enum)Enum.ToObject(typeof(KeyCode), keyCode.intValue)); hold.boolValue = EditorGUILayout.ToggleLeft("Hold", hold.boolValue, new [] { GUILayout.ExpandWidth(false), GUILayout.Width(100) }); EditorGUILayout.PropertyField(eventTargets.GetArrayElementAtIndex(i), GUIContent.none); URCUtility.UdonPublicEventField(eventTargets.GetArrayElementAtIndex(i), onKeyDownEvents.GetArrayElementAtIndex(i), GUIContent.none); if (GUILayout.Button("-", EditorStyles.miniButton, GUILayout.ExpandWidth(false))) { keyCodes.DeleteArrayElementAtIndex(i); eventTargets.DeleteArrayElementAtIndex(i); onKeyDownEvents.DeleteArrayElementAtIndex(i); } } } if (GUILayout.Button("Add Element")) { keyCodes.arraySize++; eventTargets.arraySize = keyCodes.arraySize; onKeyDownEvents.arraySize = keyCodes.arraySize; } } EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(KeyboardInput.holdTime))); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(KeyboardInput.eventsPerSeconds))); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(KeyboardInput.audioSource))); EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(KeyboardInput.audioClip))); serializedObject.ApplyModifiedProperties(); }