Example #1
0
        internal static void    LoadSharedNGSetting(bool skipLoad = false)
        {
            if (skipLoad == false && NGSettings.sharedSettings != null)
            {
                HQ.SetSettings(NGSettings.sharedSettings);
                return;
            }

            NGSettings asset = null;

            if (skipLoad == false)
            {
                asset = NGSettings.LoadSharedSettings();
                if (asset != null)
                {
                    asset.hideFlags = HideFlags.DontSave;
                }
            }

            if (skipLoad == true || asset == null)
            {
                asset           = NGSettings.CreateSharedSettings();
                asset.hideFlags = HideFlags.DontSave;

                Directory.CreateDirectory(Path.GetDirectoryName(NGSettings.GetSharedSettingsPath()));
                HQ.SaveSharedNGSettings(asset);
            }
            else
            {
                NGSettings.sharedSettings = asset;
            }

            HQ.SetSettings(asset);
        }
Example #2
0
        public static void      CreateNGSettings(string path)
        {
            try
            {
                NGSettings asset = ScriptableObject.CreateInstance <NGSettings>();

                AssetDatabase.CreateAsset(asset, path);
                AssetDatabase.SaveAssets();

                NGEditorPrefs.SetString(Constants.ConfigPathKeyPref, path, true);

                HQ.SetSettings(asset);

                // Need to skip many frames before really writing the data. Don't know why it requires 2 frames.
                EditorApplication.delayCall += () =>
                {
                    EditorApplication.delayCall += () =>
                    {
                        HQ.InvalidateSettings();
                        AssetDatabase.SaveAssets();
                    };
                };
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException(ex);
                HQ.SetSettings(null);
            }
        }
Example #3
0
 private static void     ResetAssets()
 {
     if (HQ.settings == null)
     {
         NGEditorPrefs.DeleteKey(Constants.ConfigPathKeyPref, true);
         GUICallbackWindow.Open(() => HQ.LoadSharedNGSetting());
     }
 }
Example #4
0
        public static void      SetSettings(NGSettings settings)
        {
            HQ.LastSettings = HQ.settings;
            HQ.settings     = settings;

            if (HQ.SettingsChanged != null)
            {
                HQ.SettingsChanged();
            }
        }
Example #5
0
        private static void     CheckSettingsVersion()
        {
            if (HQ.settings != null && HQ.settings.version != NGSettings.Version)
            {
                EditorApplication.delayCall += () =>
                {
                    if (EditorUtility.DisplayDialog(Constants.PackageTitle, string.Format(LC.G("Preferences_AskResetSettings"), HQ.settings.version, NGSettings.Version), LC.G("Yes"), LC.G("No")) == true)
                    {
                        GUICallbackWindow.Open(() =>
                        {
                            SerializedObject obj   = new SerializedObject(HQ.settings);
                            NGSettings newSettings = ScriptableObject.CreateInstance <NGSettings>();

                            newSettings.hideFlags = HQ.settings.hideFlags;

                            if (NGSettings.sharedSettings == HQ.settings)
                            {
                                File.Delete(NGSettings.GetSharedSettingsPath());
                                NGSettings.sharedSettings = newSettings;
                            }

                            SerializedObject newObject = new SerializedObject(newSettings);
                            SerializedProperty it      = obj.GetIterator();

                            it.Next(true);

                            SerializedProperty end = it.GetEndProperty();

                            while (SerializedProperty.EqualContents(it, end) == false && it.Next(true) == true)
                            {
                                newObject.CopyFromSerializedProperty(it);
                            }

                            newObject.ApplyModifiedProperties();

                            string path = AssetDatabase.GetAssetPath(HQ.settings.GetInstanceID());

                            if (string.IsNullOrEmpty(path) == false)
                            {
                                AssetDatabase.CreateAsset(newSettings, path);
                            }

                            HQ.settings = newSettings;

                            if (HQ.SettingsChanged != null)
                            {
                                HQ.SettingsChanged();
                            }
                        });
                    }
                };
            }
        }
Example #6
0
        internal static void    SetSendStats(object sendStats)
        {
            if ((bool)sendStats == false)
            {
                if (EditorUtility.DisplayDialog(Constants.PackageTitle, "For those who might want to know why I send stats.\nI need some info about Unity Editor usage, especially because Unity does not provide them.\nIn order to keep supporting legacy versions, unused tools or platforms such as Unity 4, Mac or else.\n\nDo you confirm not sending stats?", "Yes", "No") == false)
                {
                    return;
                }

                HQ.SendStats(false);
            }

            NGEditorPrefs.SetBool(HQ.AllowSendStatsKeyPref, (bool)sendStats);
        }
Example #7
0
        private static void     SaveSharedNGSettings(NGSettings settings = null, bool directSave = false)
        {
            if (settings == null)
            {
                settings = HQ.settings;
            }

            if (directSave == false)
            {
                Utility.RegisterIntervalCallback(HQ.WriteToDisk, 200, 1);
            }
            else
            {
                HQ.WriteToDisk();
            }
        }
Example #8
0
        public static void              InvalidateSettings(NGSettings settings = null, bool directSave = false)
        {
            if (settings == null)
            {
                settings = HQ.settings;
            }

            if ((settings.hideFlags & HideFlags.DontSave) == HideFlags.DontSave)
            {
                HQ.SaveSharedNGSettings(settings, directSave);
            }
            else
            {
                EditorUtility.SetDirty(settings);
            }
        }
Example #9
0
 public static void      NGComponentsInspectorWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Components Inspector", Utility.GetType("NGToolsEditor.NGComponentsInspector", "NGComponentsInspectorWindow"), "Open");
 }
Example #10
0
 public static void      NGAssetFinderWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Asset Finder	[BETA]", Utility.GetType("NGToolsEditor.NGAssetFinder", "NGAssetFinderWindow"), "Open");
 }
Example #11
0
 public static void      TransparentTestWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "Trans Test", Utility.GetType("NGToolsEditor.NGSmartMenu", "TransparentTestWindow"), "Open");
 }
Example #12
0
 public static void      MenuContainerEditorOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "Menu Container Editor", Utility.GetType("NGToolsEditor.NGSmartMenu", "MenuContainerEditor"), "Open");
 }
Example #13
0
 public static void      NGSpotlightWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Spotlight	[ALPHA]", Utility.GetType("NGToolsEditor.NGSpotlight", "NGSpotlightWindow"), "Open");
 }
Example #14
0
 public static void      NGReplayWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Replay", Utility.GetType("NGToolsEditor.NGRemoteScene", "NGReplayWindow"), "Open");
 }
Example #15
0
 public static void      NGMissingScriptRecoveryWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Missing Script Recovery", Utility.GetType("NGToolsEditor.NGMissingScriptRecovery", "NGMissingScriptRecoveryWindow"), "Open");
 }
Example #16
0
        private static void     OnGUISettings()
        {
            if (HQ.Settings == null)
            {
                return;
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical(GUILayoutOptionPool.ExpandWidthTrue);
                GUILayout.Label("Bind a MenuItem with a custom hotkey.", GeneralStyles.SmallLabel);
                if (GUILayout.Button("Help", GUILayoutOptionPool.Width(50F)) == true)
                {
                    Application.OpenURL("https://docs.unity3d.com/ScriptReference/MenuItem.html");
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.BeginVertical(GUILayoutOptionPool.Width(130F));
                if (EditorApplication.isCompiling == true)
                {
                    using (BgColorContentRestorer.Get(GeneralStyles.HighlightResultButton))
                    {
                        GUILayout.Button("Compiling...", GeneralStyles.BigButton);
                    }
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(NGHotkeys.DetectDiff(true) == false);
                    if (GUILayout.Button("Save", GeneralStyles.BigButton) == true)
                    {
                        NGHotkeys.Generate();
                        HQ.InvalidateSettings(HQ.Settings, true);
                    }
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            Rect r2 = GUILayoutUtility.GetLastRect();

            r2.x      = 2F;
            r2.width += 13F;
            r2.yMin   = r2.yMax - 1F;
            EditorGUI.DrawRect(r2, Color.gray);

            CustomHotkeysSettings settings = HQ.Settings.Get <CustomHotkeysSettings>();

            NGHotkeys.scrollPosition = EditorGUILayout.BeginScrollView(NGHotkeys.scrollPosition);
            {
                for (int i = 0; i < NGHotkeys.shortcuts.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        MenuItemShortcut shortcut = NGHotkeys.shortcuts[i];
                        CustomHotkeysSettings.MethodHotkey hotkey = null;

                        for (int j = 0; j < settings.hotkeys.Count; j++)
                        {
                            if (settings.hotkeys[j].staticMethod == [email protected] + '.' + shortcut.staticMethod)
                            {
                                hotkey = settings.hotkeys[j];
                                break;
                            }
                        }

                        Utility.content.text = shortcut.name;
                        Rect r = GUILayoutUtility.GetRect(Utility.content, GUI.skin.label, GUILayoutOptionPool.Width(170F));
                        EditorGUI.PrefixLabel(r, Utility.content);

                        if (hotkey != null && string.IsNullOrEmpty(hotkey.bind) == false)
                        {
                            float w = r.width;
                            r.x    -= 1F;
                            r.width = 1F;
                            EditorGUI.DrawRect(r, Color.cyan);
                            r.x    += 1F;
                            r.width = w;
                        }

                        bool hasChanged = false;

                        EditorGUI.BeginChangeCheck();
                        r.x    += r.width;
                        r.width = 50F;
                        string bind = EditorGUI.TextField(r, hotkey != null ? hotkey.bind : string.Empty);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hasChanged = true;
                        }
                        r.x += r.width;

                        r.width = 50F;
                        EditorGUI.BeginChangeCheck();
                        GUI.Toggle(r, bind.Contains("%"), "Ctrl", GeneralStyles.ToolbarToggle);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            GUI.FocusControl(null);

                            hasChanged = true;

                            int n = bind.IndexOf('%');

                            if (n != -1)
                            {
                                bind = bind.Remove(n, 1);
                            }
                            else
                            {
                                bind = '%' + bind;
                            }
                        }
                        r.x += r.width;

                        EditorGUI.BeginChangeCheck();
                        GUI.Toggle(r, bind.Contains("#"), "Shift", GeneralStyles.ToolbarToggle);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            GUI.FocusControl(null);

                            hasChanged = true;

                            int n = bind.IndexOf('#');

                            if (n != -1)
                            {
                                bind = bind.Remove(n, 1);
                            }
                            else
                            {
                                bind = '#' + bind;
                            }
                        }
                        r.x += r.width;

                        EditorGUI.BeginChangeCheck();
                        GUI.Toggle(r, bind.Contains("&"), "Alt", GeneralStyles.ToolbarToggle);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            GUI.FocusControl(null);

                            hasChanged = true;

                            int n = bind.IndexOf('&');

                            if (n != -1)
                            {
                                bind = bind.Remove(n, 1);
                            }
                            else
                            {
                                bind = '&' + bind;
                            }
                        }

                        if (hasChanged == true)
                        {
                            if (string.IsNullOrEmpty(bind) == true)
                            {
                                if (hotkey != null)
                                {
                                    settings.hotkeys.Remove(hotkey);
                                }
                            }
                            else
                            {
                                if (hotkey == null)
                                {
                                    settings.hotkeys.Add(new CustomHotkeysSettings.MethodHotkey {
                                        staticMethod = [email protected] + '.' + shortcut.staticMethod, bind = bind
                                    });
                                }
                                else
                                {
                                    hotkey.bind = bind;
                                }
                            }
                        }

                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();

                    GUILayout.Space(5F);
                }
            }
            EditorGUILayout.EndScrollView();
        }
Example #17
0
 public static void      ExternalNGFullscreenBindingsToggleFullscreenF9()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Fullscreen Bindings/Asset Store _F9", Utility.GetType("NGToolsEditor.NGFullscreenBindings", "ExternalNGFullscreenBindings"), "ToggleFullscreenF9");
 }
Example #18
0
 public static void      NGFavWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Fav", Utility.GetType("NGToolsEditor.NGFav", "NGFavWindow"), "Open");
 }
Example #19
0
 public static void      AboutWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "About", Utility.GetType("NGToolsEditor", "AboutWindow"), "Open");
 }
Example #20
0
        private static bool     DetectDiff(bool silent)
        {
            if (HQ.Settings == null || NGHotkeys.isGenerating == true)
            {
                return(false);
            }

            CustomHotkeysSettings settings = HQ.Settings.Get <CustomHotkeysSettings>();
            bool isDifferent = false;

            Type type = Utility.GetType("NGToolsEditor", "CustomHotkeys");

            if (type != null)
            {
                MethodInfo[] methods = type.GetMethods(BindingFlags.Public | BindingFlags.Static);

                if (methods.Length != settings.hotkeys.Count)
                {
                    isDifferent = true;
                }
                else
                {
                    MenuItem[][] attributes = new MenuItem[methods.Length][];

                    for (int i = 0; i < methods.Length; i++)
                    {
                        attributes[i] = methods[i].GetCustomAttributes(typeof(MenuItem), false) as MenuItem[];
                    }

                    for (int i = 0; i < settings.hotkeys.Count; i++)
                    {
                        CustomHotkeysSettings.MethodHotkey binding = settings.hotkeys[i];

                        for (int j = 0; j < NGHotkeys.shortcuts.Count; j++)
                        {
                            MenuItemShortcut shortcut = NGHotkeys.shortcuts[j];

                            if ([email protected] + '.' + shortcut.staticMethod == binding.staticMethod)
                            {
                                for (int k = 0; k < attributes.Length; k++)
                                {
                                    for (int l = 0; l < attributes[k].Length; l++)
                                    {
                                        string s = Constants.MenuItemPath + NGHotkeys.SubMenuItemPath + shortcut.name + "	_";

                                        if (attributes[k][l].menuItem.StartsWith(s) == true)
                                        {
                                            if (attributes[k][l].menuItem.Substring(s.Length) != binding.bind)
                                            {
                                                isDifferent = true;
                                                goto quadrupleBreaks;
                                            }

                                            goto doubleBreaks;
                                        }
                                    }
                                }

doubleBreaks:

                                break;
                            }
                        }
                    }
                }
            }
            else if (settings.hotkeys.Count > 0)
            {
                isDifferent = true;
            }

quadrupleBreaks:
            if (isDifferent == true && silent == false)
            {
                EditorApplication.delayCall += () =>
                {
                    if (EditorUtility.DisplayDialog(NGHotkeys.Title, "The current hotkeys bindings do not match your settings.\nThis might happen after an update of NG Tools.\n\nDo you want to restore your setup?", LC.G("Yes"), LC.G("No")) == true)
                    {
                        NGHotkeys.isGenerating = true;
                        NGHotkeys.Generate();
                        HQ.InvalidateSettings(HQ.Settings, true);
                    }
                };
            }

            return(isDifferent);
        }
Example #21
0
        static HQ()
        {
            HQ.rootPath = Utility.GetPackagePath();
            NGDiagnostic.Log(Preferences.Title, "RootPath", HQ.RootPath);

            if (HQ.RootPath == string.Empty)
            {
                InternalNGDebug.LogWarning(Constants.RootFolderName + " folder was not found.");
                return;
            }

            HQ.SettingsChanged += HQ.CheckSettingsVersion;

            string[] files = Directory.GetFiles(HQ.RootPath, HQ.NestedNGMenuItems, SearchOption.AllDirectories);
            if (files.Length == 1)
            {
                HQ.rootedMenuFilePath = files[0];
            }

            NGLicensesManager.LicensesLoaded += () =>
            {
                NGDiagnostic.Log(Preferences.Title, "AllowSendStats", NGEditorPrefs.GetBool(HQ.AllowSendStatsKeyPref, true));
                if (NGEditorPrefs.GetBool(HQ.AllowSendStatsKeyPref, true) == true)
                {
                    HQ.SendStats();
                }
            };
            NGLicensesManager.ActivationSucceeded += (invoice) =>
            {
                string path = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, "sendStats." + Utility.UnityVersion + "." + Constants.Version + ".txt"));

                if (File.Exists(path) == true)
                {
                    File.Delete(path);
                }
            };

            //Conf.DebugMode = (Conf.DebugState)EditorPrefs.GetInt(Conf.DebugModeKeyPref, (int)Conf.DebugMode);
            Utility.SafeDelayCall(() =>
            {
                NGLicensesManager.Title            = Constants.PackageTitle;
                NGLicensesManager.IntermediatePath = Constants.InternalPackageTitle;

                NGDiagnostic.Log(Preferences.Title, "LogPath", InternalNGDebug.LogPath);
            });

            NGDiagnostic.Log(Preferences.Title, "DebugMode", Conf.DebugMode);

            // TODO Unity <5.6 backward compatibility?
            MethodInfo ResetAssetsMethod = typeof(HQ).GetMethod("ResetAssets", BindingFlags.Static | BindingFlags.NonPublic);

            try
            {
                EventInfo projectChangedEvent = typeof(EditorApplication).GetEvent("projectChanged");
                projectChangedEvent.AddEventHandler(null, Delegate.CreateDelegate(projectChangedEvent.EventHandlerType, null, ResetAssetsMethod));
                //EditorApplication.projectChanged += HQ.ResetAssets;
            }
            catch
            {
                FieldInfo projectWindowChangedField = UnityAssemblyVerifier.TryGetField(typeof(EditorApplication), "projectWindowChanged", BindingFlags.Static | BindingFlags.Public);
                if (projectWindowChangedField != null)
                {
                    projectWindowChangedField.SetValue(null, Delegate.Combine((Delegate)projectWindowChangedField.GetValue(null), Delegate.CreateDelegate(projectWindowChangedField.FieldType, null, ResetAssetsMethod)));
                }
                //EditorApplication.projectWindowChanged += HQ.ResetAssets;
            }

            EditorApplication.projectWindowItemOnGUI += ProjectCopyAssets.OnProjectElementGUI;
        }
Example #22
0
 public static void      PreferencesGetNGLog()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "Get NG Log", Utility.GetType("NGToolsEditor", "Preferences"), "GetNGLog");
 }
Example #23
0
        /// <summary>
        /// For the curious who might want to know why I send these stats.
        /// I need some info about Unity Editor usage, especially because Unity does not provide them.
        /// In order to keep supporting old versions or platforms.
        /// </summary>
        /// <param name="sendStats"></param>
        internal static void    SendStats(bool sendStats = true)
        {
            string path     = Path.Combine(Application.persistentDataPath, Path.Combine(Constants.InternalPackageTitle, "sendStats." + Utility.UnityVersion + "." + Constants.Version + ".txt"));
            bool   sentOnce = false;
            string today    = DateTime.Now.ToString("yyyyMMdd");

            if (File.Exists(path) == true)
            {
                string lastTime = File.ReadAllText(path);

                if (lastTime == today)
                {
                    sentOnce = true;
                }
            }

            if (sentOnce == false)
            {
                try
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(path));
                    File.WriteAllText(path, today);
                }
                catch
                {
                    string rawSentOnceCount = HQ.GetStatsComplementary("SSSOC");
                    int    errorCount;

                    if (string.IsNullOrEmpty(rawSentOnceCount) == false && int.TryParse(rawSentOnceCount, out errorCount) == true)
                    {
                        HQ.SetStatsComplementary("SSSOC", (errorCount + 1).ToString());
                    }
                    else
                    {
                        HQ.SetStatsComplementary("SSSOC", "1");
                    }
                }
            }

            if (sentOnce == false || sendStats == false)
            {
                StringBuilder buffer = Utility.GetBuffer(HQ.ServerEndPoint + "unityeditor.php?u=");

                buffer.Append(Utility.UnityVersion);
                buffer.Append("&o=");
                buffer.Append(SystemInfo.operatingSystem);
                buffer.Append("&p=");
                buffer.Append(Constants.Version);
                buffer.Append("&n=");
                buffer.Append(SystemInfo.deviceName);
                buffer.Append("&un=");
                buffer.Append(Environment.UserName);
                buffer.Append("&ut=");
                buffer.Append(Metrics.GetUsedTools());
                Metrics.ResetUsedTools();

                buffer.Append("&m=");
                buffer.Append(HQ.GetMACAddressHash());

                foreach (License license in NGLicensesManager.EachInvoices())
                {
                    if (license.active == true && license.status != Status.Banned)
                    {
                        buffer.Append("&in[]=");
                        buffer.Append(license.invoice);
                    }
                }

                foreach (HQ.ToolAssemblyInfo tool in HQ.EachTool)
                {
                    buffer.Append("&to[]=");
                    buffer.Append(tool.name);
                    buffer.Append(":");
                    buffer.Append(tool.version);
                }

                string complementary = NGEditorPrefs.GetString(HQ.ComplementaryKeyPref);
                if (string.IsNullOrEmpty(complementary) == false)
                {
                    buffer.Append("&com=" + complementary);
                }

                if (sendStats == false)
                {
                    buffer.Append("&s");
                }

                Utility.RequestURL(Utility.ReturnBuffer(buffer), (s, r) =>
                {
                    if (s == Utility.RequestStatus.Completed)
                    {
                        NGEditorPrefs.DeleteKey(HQ.ComplementaryKeyPref);
                    }
                    else
                    {
                        string rawErrorCount = HQ.GetStatsComplementary("SSEC");
                        int errorCount;

                        if (string.IsNullOrEmpty(rawErrorCount) == false && int.TryParse(rawErrorCount, out errorCount) == true)
                        {
                            HQ.SetStatsComplementary("SSEC", (errorCount + 1).ToString());
                        }
                        else
                        {
                            HQ.SetStatsComplementary("SSEC", "1");
                        }
                    }
                });
            }
        }
Example #24
0
 public static void      ExternalNGFullscreenBindingsToggleFullscreenF3()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Fullscreen Bindings/Inspector _F3", Utility.GetType("NGToolsEditor.NGFullscreenBindings", "ExternalNGFullscreenBindings"), "ToggleFullscreenF3");
 }
Example #25
0
 public static void      NGHubWindowOpenAsDock()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Hub as Dock", Utility.GetType("NGToolsEditor.NGHub", "NGHubWindow"), "OpenAsDock");
 }
Example #26
0
 public static void      NGFullscreenBindingsWindowOpen()
 {
     HQ.Invoke(ExternalNGMenuItems.MenuItemPath + "NG Fullscreen Bindings/Edit", Utility.GetType("NGToolsEditor.NGFullscreenBindings", "NGFullscreenBindingsWindow"), "Open");
 }
Example #27
0
        public void     OnGUI()
        {
            if (HQ.Settings == null)
            {
                this.so = null;
                GUILayout.Label(LC.G("ConsoleSettings_NullTarget"));
                return;
            }

            try
            {
                if (this.so == null || this.so.targetObject == null || this.so.targetObject != HQ.Settings.Get(this.typeSetting) as ScriptableObject)
                {
                    this.so = new SerializedObject(HQ.Settings.Get(this.typeSetting) as ScriptableObject);
                }
                else
                {
                    this.so.Update();
                }
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException("Setting " + this.typeSetting + " is failing. (" + HQ.Settings.Get(this.typeSetting) + ")", ex);
                return;
            }

            GUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();

                if (GUILayout.Button("Reset", GUILayoutOptionPool.ExpandWidthFalse) == true &&
                    ((Event.current.modifiers & Constants.ByPassPromptModifier) != 0 || EditorUtility.DisplayDialog(NGSettingsWindow.Title, LC.G("ConsoleSettings_ResetConfirm"), LC.G("Yes"), LC.G("No")) == true))
                {
                    if (this.typeSetting.IsSubclassOf(typeof(ScriptableObject)) == true)
                    {
                        this.so = null;
                        // Delete the current settings.
                        HQ.Settings.Clear(this.typeSetting);
                        // Then regenerate it to ensure it exists and is called from OnGUI context.
                        HQ.Settings.Get(this.typeSetting);
                    }
                    else
                    {
                        object settings = Activator.CreateInstance(this.fieldInfo.FieldType);

                        this.fieldInfo.SetValue(HQ.Settings, settings);
                    }

                    HQ.InvalidateSettings();
                    InternalEditorUtility.RepaintAllViews();
                    return;
                }
            }
            GUILayout.EndHorizontal();

            if (this.typeSetting.IsSubclassOf(typeof(ScriptableObject)) == true)
            {
                SerializedProperty iterator = this.so.GetIterator();

                iterator.NextVisible(true);

                EditorGUI.BeginChangeCheck();

                while (iterator.NextVisible(false) == true)
                {
                    EditorGUILayout.PropertyField(iterator, true);
                }

                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.so.ApplyModifiedProperties();
                    HQ.InvalidateSettings();
                }
            }
            else
            {
                SerializedProperty iterator = this.so.FindProperty(this.fieldInfo.Name);
                SerializedProperty end      = iterator.GetEndProperty();
                bool enterChildren          = true;

                EditorGUI.BeginChangeCheck();

                while (iterator.NextVisible(enterChildren) == true && SerializedProperty.EqualContents(iterator, end) == false)
                {
                    EditorGUILayout.PropertyField(iterator, true);
                    enterChildren = false;
                }

                if (EditorGUI.EndChangeCheck() == true)
                {
                    this.so.ApplyModifiedProperties();
                    HQ.InvalidateSettings();
                }
            }
        }