public static void DrawModuleSettingsGUI(IWindowFlowAddon addon, string caption, GenericMenu settingsMenu, System.Action onGUI) { //CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f)); var key = "UI.Windows.Addons." + caption + ":foldout"; var show = EditorPrefs.GetBool(key, true); GUILayout.BeginHorizontal(); { var style = ME.Utilities.CacheStyle("UI.Windows.Settings.AddonToggle", "Toggle", (name) => { return(FlowSystemEditorWindow.defaultSkin.FindStyle("SettingsAddonToggle")); }); var styleSelected = ME.Utilities.CacheStyle("UI.Windows.Settings.AddonToggle", "ToggleSelected", (name) => { return(FlowSystemEditorWindow.defaultSkin.FindStyle("SettingsAddonToggleSelected")); }); var newShow = GUILayout.Toggle(show, caption.ToSentenceCase().UppercaseWords(), show == true ? styleSelected : style); var rect = GUILayoutUtility.GetLastRect(); if (GUI.enabled == true) { EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link); } if (rect.Contains(Event.current.mousePosition) == true) { FlowSystemEditorWindow.GetWindow <FlowSystemEditorWindow>().Repaint(); } if (newShow != show) { show = newShow; EditorPrefs.SetBool(key, show); } if (settingsMenu != null) { var settingsStyle = new GUIStyle("PaneOptions"); if (GUILayout.Button(string.Empty, settingsStyle) == true) { settingsMenu.ShowAsContext(); } } } GUILayout.EndHorizontal(); //CustomGUI.Splitter(new Color(0.7f, 0.7f, 0.7f, 0.2f)); if (show == true) { GUILayout.BeginVertical(FlowSystemEditorWindow.defaultSkin.box); { if (addon != null && addon.InstallationNeeded() == true) { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayoutExt.LargeButton("Install", 40f, 200f) == true) { addon.Install(); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } else { onGUI(); } } GUILayout.EndVertical(); } }
/// <summary> /// Update Unity Editor Preferences static void UpdateUnityPreferences(bool enabled) { if (enabled) { #if UNITY_EDITOR_OSX var newPath = "/Applications/Visual Studio Code.app"; #elif UNITY_EDITOR_WIN //var newPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.LocalApplicationData) + Path.DirectorySeparatorChar + "Code" + Path.DirectorySeparatorChar + "bin" + Path.DirectorySeparatorChar + "code.cmd"; var newPath = "code"; #else var newPath = "/usr/local/bin/code"; #endif // App if (EditorPrefs.GetString("kScriptsDefaultApp") != newPath) { EditorPrefs.SetString("VSCode_PreviousApp", EditorPrefs.GetString("kScriptsDefaultApp")); } EditorPrefs.SetString("kScriptsDefaultApp", newPath); // Arguments if (EditorPrefs.GetString("kScriptEditorArgs") != "-r -g \"$(File):$(Line)\"") { EditorPrefs.SetString("VSCode_PreviousArgs", EditorPrefs.GetString("kScriptEditorArgs")); } EditorPrefs.SetString("kScriptEditorArgs", "-r -g \"$(File):$(Line)\""); EditorPrefs.SetString("kScriptEditorArgs" + newPath, "-r -g \"$(File):$(Line)\""); // MonoDevelop Solution if (EditorPrefs.GetBool("kMonoDevelopSolutionProperties", false)) { EditorPrefs.SetBool("VSCode_PreviousMD", true); } EditorPrefs.SetBool("kMonoDevelopSolutionProperties", false); // Support Unity Proj (JS) if (EditorPrefs.GetBool("kExternalEditorSupportsUnityProj", false)) { EditorPrefs.SetBool("VSCode_PreviousUnityProj", true); } EditorPrefs.SetBool("kExternalEditorSupportsUnityProj", false); // Attach to Editor if (!EditorPrefs.GetBool("AllowAttachedDebuggingOfEditor", false)) { EditorPrefs.SetBool("VSCode_PreviousAttach", false); } EditorPrefs.SetBool("AllowAttachedDebuggingOfEditor", true); } else { // Restore previous app if (!string.IsNullOrEmpty(EditorPrefs.GetString("VSCode_PreviousApp"))) { EditorPrefs.SetString("kScriptsDefaultApp", EditorPrefs.GetString("VSCode_PreviousApp")); } // Restore previous args if (!string.IsNullOrEmpty(EditorPrefs.GetString("VSCode_PreviousArgs"))) { EditorPrefs.SetString("kScriptEditorArgs", EditorPrefs.GetString("VSCode_PreviousArgs")); } // Restore MD setting if (EditorPrefs.GetBool("VSCode_PreviousMD", false)) { EditorPrefs.SetBool("kMonoDevelopSolutionProperties", true); } // Restore MD setting if (EditorPrefs.GetBool("VSCode_PreviousUnityProj", false)) { EditorPrefs.SetBool("kExternalEditorSupportsUnityProj", true); } // Restore previous attach if (!EditorPrefs.GetBool("VSCode_PreviousAttach", true)) { EditorPrefs.SetBool("AllowAttachedDebuggingOfEditor", false); } } FixUnityPreferences(); }