public void OnGUI() { BeginHorizontal(EditorStyles.toolbar); DrawMenus(); EditorGUILayout.Space(); Label(map ? map.name : "Not loaded"); FlexibleSpace(); if (Button("Show in folder", EditorStyles.toolbarButton)) { ShowInFolder(); } if (Toggle(map && InputMapWindow.AutoSave, "Auto save", EditorStyles.toolbarButton) != InputMapWindow.AutoSave) { InputMapWindow.AutoSave = !InputMapWindow.AutoSave; } if (Button("Save", EditorStyles.toolbarButton)) { InputMapWindow.Save(); } EditorGUILayout.Space(); EndHorizontal(); }
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 OpenAsset() { string path = EditorUtility.OpenFilePanel("Open input map", "", "asset"); //The window was closed if (string.IsNullOrEmpty(path)) { return; } //User tried opening a file outside of the project if (!path.StartsWith(Application.dataPath)) { OpenError("Cannot open Input Map that is outside of the project!"); return; } path = $"Assets{path.Remove(0, Application.dataPath.Length)}"; UnityObject obj = AssetDatabase.LoadAssetAtPath(path, typeof(ScriptableObject)); //Wrong file type if (!(obj is InputMap)) { OpenError("Please select an Input Map!"); return; } InputMapWindow.OpenMap(obj as InputMap); }
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);
public override void OnInspectorGUI() { if (InputMapWindow.DebugMode) { base.OnInspectorGUI(); } InputMap map = (InputMap)target; if (GUILayout.Button("Open editor", qGUIInternalUtility.Styles.OpenButton)) { InputMapWindow.OpenMapIfNotDirty(map); } }
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); }); } }
public override void Add(int index, InputGroup group) { base.Add(index, group); InputMapWindow.SetMapDirty(); }
public override void SetAsDefault(int index) { base.SetAsDefault(index); InputMapWindow.SetMapDirty(); }
public override void DeleteGroup(int index) { base.DeleteGroup(index); InputMapWindow.SetMapDirty(); }