public void OnGUI() { _scroll = BeginScrollView(_scroll); switch (_inspectionObject) { case InputGroup group: group.groupName = NameField(group.groupName); if (DeleteButton()) { OnDeleteGroup.Invoke(group); } break; case InspectorInputAction action: action.action.actionName = NameField(action.action.actionName); DisplayKeys(action.action); Space(); if (DeleteButton()) { OnDeleteAction.Invoke(action); } break; case InspectorInputAxis axis: axis.axis.axisName = NameField(axis.axis.axisName); EditorChangeChecker.BeginChangeCheck(InputMapWindow.SetMapDirty); axis.axis.positiveAction = TextField("Positive", axis.axis.positiveAction); axis.axis.negativeAction = TextField("Negative", axis.axis.negativeAction); EditorChangeChecker.EndChangeCheckAndCleanup(); if (DeleteButton()) { OnDeleteAxis.Invoke(axis); } break; case InputAction _: HelpBox(new GUIContent($"Use '{nameof(InspectorInputAction)}' instead of '{nameof(InputAction)}'!")); break; case InputAxis _: HelpBox(new GUIContent($"Use '{nameof(InspectorInputAxis)}' instead of '{nameof(InputAxis)}'!")); break; } EndScrollView(); if (OnNextRepaint != null && Event.current.type == EventType.Repaint) { OnNextRepaint?.Invoke(); OnNextRepaint = null; InputMapWindow.GetEditorWindow().Repaint(); } }
void DisplayKeys(InputAction action) { actionKeyFoldout = Foldout(actionKeyFoldout, "Keys", true, EditorStyles.foldoutHeader); if (!actionKeyFoldout) { return; } BeginVertical(new GUIStyle() { margin = new RectOffset((int)EditorGUIUtility.singleLineHeight, 0, 0, 0) }); //Checking for changes EditorChangeChecker.BeginChangeCheck(InputMapWindow.SetMapDirty); for (int i = 0; i < action.keys.Count; i++) { //Listening for key if (_currentListeningKeyCode == i) { if (Event.current.isKey) { action.keys[i] = Event.current.keyCode; _currentListeningKeyCode = -1; InputMapWindow.GetEditorWindow().Repaint(); } if (EditorChangeChecker.IgnorableButton("Cancel") || Event.current.isMouse) { _currentListeningKeyCode = -1; InputMapWindow.GetEditorWindow().Repaint(); } continue; } //Drawing normal line BeginHorizontal(); action.keys[i] = KeyCodePopup(action.keys[i]); if (EditorChangeChecker.IgnorableButton("Change", GUILayout.Width(60f))) { _currentListeningKeyCode = i; GUI.FocusControl(null); } if (GUILayout.Button("-", GUILayout.Width(EditorGUIUtility.singleLineHeight))) { action.keys.RemoveAt(i); } EndHorizontal(); } if (GUILayout.Button("+")) { action.keys.Add(default);
void DrawMenus() { DisplayMenu("File", ref fileMenuRect, (GenericMenu menu) => { InputMapWindow window = InputMapWindow.GetEditorWindow(); menu.AddToggableItem("Save", false, InputMapWindow.Save, map); menu.AddToggableItem("Auto save", InputMapWindow.AutoSave, () => { InputMapWindow.AutoSave = !InputMapWindow.AutoSave; }, map); menu.AddToggableItem("Show in folder", false, ShowInFolder, map); menu.AddSeparator(""); menu.AddItem("Open", false, OpenAsset); menu.AddToggableItem("Discard changes", false, window.DiscardChanges, map); menu.AddSeparator(""); menu.AddItem("Close", false, InputMapWindow.GetEditorWindow().Close); }); DisplayMenu("Help", ref helpMenuRect, (GenericMenu menu) => { menu.AddItem("Documentation", false, () => Application.OpenURL("https://docs.qasictools.com/input/getting-started")); menu.AddDisabledItem("Guides", false /*, () => Application.OpenURL("https://docs.qasictools.com/")*/); menu.AddSeparator(""); menu.AddItem("Support", false, () => Application.OpenURL("https://qasictools.com/support")); }); if (InputMapWindow.DebugMode) { DisplayMenu("Debug", ref debugMenuRect, (GenericMenu menu) => { InputMapWindow window = InputMapWindow.GetEditorWindow(); menu.AddItem("Update name", false, window.SetWindowTitle); menu.AddItem("Reset editor", false, window.ResetEditor); menu.AddItem("Reload trees", false, window.ReloadTrees); menu.AddItem("Reset preferences", false, InputMapWindow.ResetPreferences); menu.AddSeparator(""); menu.AddToggableItem("Set dirty", false, InputMapWindow.SetMapDirty, map && !InputMapWindow.AutoSave); menu.AddToggableItem("Close map", false, InputMapWindow.CloseMap, map); }); } }