示例#1
0
        private static void     OnSettingsGenerated(ScriptableObject settings)
        {
            if (EditorGUIUtility.isProSkin == true)
            {
                return;
            }

            Action OverrideSettings = () =>
            {
                if (settings is GeneralSettings)
                {
                    LightTheme.SetGeneralSettings(settings as GeneralSettings);
                }
                else if (settings is LogSettings)
                {
                    LightTheme.SetLogSettings(settings as LogSettings);
                }
                else if (settings is StackTraceSettings)
                {
                    LightTheme.SetStackTraceSettings(settings as StackTraceSettings);
                }
            };

            if (Utility.CheckOnGUI() == false)
            {
                GUICallbackWindow.Open(OverrideSettings);
            }
            else
            {
                OverrideSettings();
            }
        }
示例#2
0
        private static void     OnSettingsGenerated(ScriptableObject asset)
        {
            RemoteModuleSettings remoteSettings = asset as RemoteModuleSettings;

            if (remoteSettings != null)
            {
                Action OverrideSettings = () =>
                {
                    remoteSettings.HighlightedMatchStyle = new GUIStyle(GUI.skin.label);
                    remoteSettings.HighlightedMatchStyle.normal.textColor = new Color(219F / 255F, 219F / 255F, 219F / 255F, 1F);
                    remoteSettings.HighlightedMatchStyle.richText         = true;
                    remoteSettings.CommandInputStyle = new GUIStyle(GUI.skin.textField);
                    //remoteSettings.commandInputStyle.normal.background = AssetDatabase.LoadAssetAtPath<Texture2D>(Path.Combine(HQ.RootPath, "NGGameConsole/Textures/commandInputBg.png"));
                    remoteSettings.ExecButtonStyle           = new GUIStyle("ToolbarButton");
                    remoteSettings.ExecButtonStyle.fontStyle = FontStyle.Bold;
                };

                if (Utility.CheckOnGUI() == false)
                {
                    GUICallbackWindow.Open(OverrideSettings);
                }
                else
                {
                    OverrideSettings();
                }
            }
        }
示例#3
0
        private void    EditFilter(object rawData)
        {
            try
            {
                object[]     data    = (object[])rawData;
                Rect         v       = (Rect)data[1];
                EditorWindow console = EditorWindow.focusedWindow;

                // Must force the call in a GUI context, Unity >2017 does not like the normal way.
                GUICallbackWindow.Open(() =>
                {
                    FilterPopup window = new FilterPopup(console, data[0] as ILogFilter, this.OnFilterAltered);
                    PopupWindow.Show(new Rect(console.position.x, console.position.y + v.y - 4F, 0F, 0F), window);
                });
            }
            catch (ExitGUIException)
            {
            }
        }
示例#4
0
        protected virtual void  OnEnable()
        {
            Utility.RegisterWindow(this);
            Utility.RestoreIcon(this, NGConsoleWindow.TitleColor);

            Metrics.UseTool(2);             // NGConsole

            if (this.initialized == true || HQ.Settings == null)
            {
                return;
            }

            NGChangeLogWindow.CheckLatestVersion(NGTools.NGConsole.NGAssemblyInfo.Name);

            try
            {
                //Debug.Log("StartEnable");
                int i = 0;

                PerWindowVars.InitWindow(this, "NGConsole");

                this.syncLogs                = new SyncLogs(this);
                this.syncLogs.EndNewLog     += this.RepaintWithModules;
                this.syncLogs.UpdateLog     += this.UpdateLog;
                this.syncLogs.NewLog        += this.ConvertNewLog;
                this.syncLogs.ResetLog      += this.LocalResetLogs;
                this.syncLogs.ClearLog      += this.Clear;
                this.syncLogs.OptionAltered += this.UpdateConsoleFlags;

                this.rows = new List <Row>(ConsoleConstants.PreAllocatedArray);

                this.r = new Rect();

                List <RowType> rowDrawerTypes = new List <RowType>();

                foreach (Type c in Utility.EachNGTSubClassesOf(typeof(Row)))
                {
                    object[] attributes = c.GetCustomAttributes(typeof(RowLogHandlerAttribute), false);

                    if (attributes.Length == 0)
                    {
                        continue;
                    }

                    MethodInfo handler = c.GetMethod(RowLogHandlerAttribute.StaticVerifierMethodName, BindingFlags.Static | BindingFlags.NonPublic);

                    if (handler == null)
                    {
                        InternalNGDebug.LogWarning("The class \"" + c + "\" inherits from \"" + typeof(Row) + "\" and has the attribute \"" + typeof(RowLogHandlerAttribute) + "\" must implement: private static bool " + RowLogHandlerAttribute.StaticVerifierMethodName + "(UnityLogEntry log).");
                        continue;
                    }

                    RowType rdt = new RowType()
                    {
                        type      = c,
                        attribute = attributes[0] as RowLogHandlerAttribute
                    };

                    rdt.attribute.handler = (Func <UnityLogEntry, bool>)Delegate.CreateDelegate(typeof(Func <UnityLogEntry, bool>), handler);

                    rowDrawerTypes.Add(rdt);
                }

                rowDrawerTypes.Sort((r1, r2) => r2.attribute.priority - r1.attribute.priority);
                NGConsoleWindow.rowDrawers = rowDrawerTypes.ToArray();

                List <Module> filteredModules = new List <Module>();

                if (HQ.Settings.Get <ConsoleSettings>().serializedModules.Count > 0)
                {
                    this.modules = HQ.Settings.Get <ConsoleSettings>().serializedModules.Deserialize <Module>();
                }

                if (this.modules == null)
                {
                    foreach (Type t in Utility.EachNGTSubClassesOf(typeof(Module)))
                    {
                        filteredModules.Add((Module)Activator.CreateInstance(t));
                    }
                }
                else
                {
                    filteredModules.AddRange(this.modules);

                    // Detect new Module.
                    foreach (Type t in Utility.EachNGTSubClassesOf(typeof(Module), c => filteredModules.Exists(m => m.GetType() == c) == false))
                    {
                        InternalNGDebug.VerboseLogFormat("Module \"{0}\" generated.", t);
                        filteredModules.Add((Module)Activator.CreateInstance(t));
                    }
                }

                this.modules        = filteredModules.ToArray();
                this.visibleModules = this.GetVisibleModules(filteredModules);

                // Initialize modules
                int id = NGConsoleWindow.StartModuleID;

                for (i = 0; i < this.modules.Length; i++)
                {
                    if (this.visibleModules.Contains(this.modules[i]) == true)
                    {
                        this.modules[i].OnEnable(this, id++);
                    }
                    else
                    {
                        this.modules[i].OnEnable(this, -1);
                    }
                }

                // Do not overflow if there is removed modules.
                if (this.visibleModules.Length > 0)
                {
                    if (this.workingModuleId == -1)
                    {
                        this.workingModuleId = this.visibleModules[0].Id;
                    }
                    else
                    {
                        this.workingModuleId = Mathf.Clamp(this.workingModuleId, NGConsoleWindow.StartModuleID, this.visibleModules.Length);
                    }

                    Module module = this.GetModule(this.workingModuleId);
                    if (module != null)
                    {
                        module.OnEnter();
                    }
                }
                else
                {
                    this.workingModuleId = -1;
                }

                GUI.FocusControl(null);

                Object[] nativeConsoleInstances = Resources.FindObjectsOfTypeAll(NGConsoleWindow.nativeConsoleType);

                if (nativeConsoleInstances.Length > 0)
                {
                    NGConsoleWindow.nativeConsoleWindowField.SetValue(null, nativeConsoleInstances[nativeConsoleInstances.Length - 1]);
                }

                this.settings = HQ.Settings;

                HQ.SettingsChanged     += this.OnSettingsChanged;
                Undo.undoRedoPerformed += this.Repaint;

                EditorApplication.delayCall += () => GUICallbackWindow.Open(this.VerifySettingsStyles);

                this.initialized = true;
            }
            catch (Exception ex)
            {
                InternalNGDebug.LogException(ex);
            }
        }