private static void OnGUISettings() { if (Utility.IsCustomEditorCompatible == false) { EditorGUILayout.HelpBox("NG Tools has detected a change in Unity code. Please contact the author.", MessageType.Error); if (GUILayout.Button("Contact the author") == true) { ContactFormWizard.Open(ContactFormWizard.Subject.BugReport, "MonoScriptEditor is incompatible with " + Utility.UnityVersion + "."); } return; } InspectorGadgetSettings settings = HQ.Settings.Get <InspectorGadgetSettings>(); EditorGUI.BeginChangeCheck(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Script visualizer lets you select the text when you inspect a script.", GeneralStyles.WrapLabel); bool active = NGEditorGUILayout.Switch("Script Visualizer", settings.activeScriptVisualizer); if (EditorGUI.EndChangeCheck() == true) { bool mustUpdate = active == true?Utility.AddCustomEditor(typeof(MonoScript), typeof(MonoScriptEditor)) : Utility.RemoveCustomEditor(typeof(MonoScriptEditor)); if (mustUpdate == true) { MonoScriptEditor.UpdateInspector(); } settings.activeScriptVisualizer = active; HQ.InvalidateSettings(); } }
static MonoScriptEditor() { NGInspectorGadget.GUISettings += MonoScriptEditor.OnGUISettings; HQ.SettingsChanged += () => { if (HQ.Settings == null) { return; } if (HQ.Settings.Get <InspectorGadgetSettings>().activeScriptVisualizer == true) { if (Utility.AddCustomEditor(typeof(MonoScript), typeof(MonoScriptEditor)) == true) { MonoScriptEditor.UpdateInspector(); } } else if (Utility.RemoveCustomEditor(typeof(MonoScriptEditor)) == true) { MonoScriptEditor.UpdateInspector(); } }; }