private void DrawElement(Rect r, int index, bool isActive, bool isFocused) { r.width -= 30F; r.x += 30F; EditorGUI.BeginChangeCheck(); ProfilesManager.profiles[index].name = EditorGUI.TextField(r, ProfilesManager.profiles[index].name); if (EditorGUI.EndChangeCheck() == true) { ProfilesManager.Save(); } r.x -= 30; r.width = 30F; if (GUI.Button(r, ">") == true) { ProfilesManager.SwitchFavorite(index); if (ProfilesManager.SetProfile != null) { ProfilesManager.SetProfile(); } InternalEditorUtility.RepaintAllViews(); this.editorWindow.Close(); } }
public static void OnProfilesBarGUI() { if (Event.current.type == EventType.KeyDown && Event.current.modifiers == EventModifiers.Control) { if (Event.current.keyCode == KeyCode.Q && ProfilesManager.current > 0) { GUI.FocusControl(null); ProfilesManager.SwitchFavorite(ProfilesManager.current - 1); } else if (Event.current.keyCode == KeyCode.E && ProfilesManager.current < ProfilesManager.profiles.Count - 1) { GUI.FocusControl(null); ProfilesManager.SwitchFavorite(ProfilesManager.current + 1); } Event.current.Use(); } EditorGUILayout.BeginHorizontal("Toolbar"); { if (ProfilesManager.profiles == null) { GUILayout.Label("Profiles not loaded yet."); } else { if (GUILayout.Button("", "ToolbarDropDown", GUILayout.Width(20F)) == true) { Rect r = GUILayoutUtility.GetLastRect(); r.y += 16F; new ProfilesPopup().Open(r); } EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(ProfilesManager.current <= 0); if (GUILayout.Button("<", "ToolbarButton", GUILayout.Width(30F)) == true) { ProfilesManager.SwitchFavorite(ProfilesManager.current - 1); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(ProfilesManager.current >= ProfilesManager.profiles.Count - 1); if (GUILayout.Button(">", "ToolbarButton", GUILayout.Width(30F)) == true) { ProfilesManager.SwitchFavorite(ProfilesManager.current + 1); } EditorGUI.EndDisabledGroup(); EditorGUI.BeginChangeCheck(); ProfilesManager.Profile.name = EditorGUILayout.TextField(ProfilesManager.Profile.name, new GUIStyle("ToolbarTextField"), GUILayout.ExpandWidth(true)); if (EditorGUI.EndChangeCheck() == true) { ProfilesManager.Save(); } } EditorGUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(ProfilesManager.profiles.Count <= 1); if (GUILayout.Button("X", "ToolbarButton") == true && EditorUtility.DisplayDialog("Profiles", "Confirm deletion of " + ProfilesManager.Profile.name, "Yes", "No") == true) { ProfilesManager.profiles.RemoveAt(ProfilesManager.current); ProfilesManager.current = Mathf.Clamp(ProfilesManager.current, 0, ProfilesManager.profiles.Count - 1); ProfilesManager.Save(); } EditorGUI.EndDisabledGroup(); } } EditorGUILayout.EndHorizontal(); }