Beispiel #1
0
        private void OnInitialize()
        {
            GUILayoutY layout      = GUI.AddLayoutY();
            GUILayoutX titleLayout = layout.AddLayoutX();

            GUIContentImages infoImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 16, true));

            GUIContentImages warningImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 16, true));

            GUIContentImages errorImages = new GUIContentImages(
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, false),
                EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 16, true));

            GUIToggle infoBtn    = new GUIToggle(new GUIContent(infoImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle warningBtn = new GUIToggle(new GUIContent(warningImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle errorBtn   = new GUIToggle(new GUIContent(errorImages), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            GUIToggle detailsBtn     = new GUIToggle(new LocEdString("Show details"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIButton clearBtn       = new GUIButton(new LocEdString("Clear"), GUIOption.FixedHeight(TITLE_HEIGHT));
            GUIToggle clearOnPlayBtn = new GUIToggle(new LocEdString("Clear on play"), EditorStyles.Button, GUIOption.FixedHeight(TITLE_HEIGHT));

            titleLayout.AddElement(infoBtn);
            titleLayout.AddElement(warningBtn);
            titleLayout.AddElement(errorBtn);
            titleLayout.AddFlexibleSpace();
            titleLayout.AddElement(detailsBtn);
            titleLayout.AddElement(clearBtn);
            titleLayout.AddElement(clearOnPlayBtn);

            infoBtn.Value    = filter.HasFlag(EntryFilter.Info);
            warningBtn.Value = filter.HasFlag(EntryFilter.Warning);
            errorBtn.Value   = filter.HasFlag(EntryFilter.Error);

            clearOnPlayBtn.Value = EditorSettings.GetBool(CLEAR_ON_PLAY_KEY, true);

            infoBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Info);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Info);
                }
            };

            warningBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Warning);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Warning);
                }
            };

            errorBtn.OnToggled += x =>
            {
                if (x)
                {
                    SetFilter(filter | EntryFilter.Error);
                }
                else
                {
                    SetFilter(filter & ~EntryFilter.Error);
                }
            };

            detailsBtn.OnToggled     += ToggleDetailsPanel;
            clearBtn.OnClick         += ClearLog;
            clearOnPlayBtn.OnToggled += ToggleClearOnPlay;

            GUILayoutX mainLayout = layout.AddLayoutX();

            listView = new GUIListView <ConsoleGUIEntry, ConsoleEntryData>(Width, ListHeight, ENTRY_HEIGHT, mainLayout);

            detailsSeparator = new GUITexture(Builtin.WhiteTexture, GUIOption.FixedWidth(SEPARATOR_WIDTH));
            detailsArea      = new GUIScrollArea(ScrollBarType.ShowIfDoesntFit, ScrollBarType.NeverShow);
            mainLayout.AddElement(detailsSeparator);
            mainLayout.AddElement(detailsArea);
            detailsSeparator.Active = false;
            detailsArea.Active      = false;

            detailsSeparator.SetTint(SEPARATOR_COLOR);

            Refresh();
            Debug.OnAdded += OnEntryAdded;
        }
Beispiel #2
0
            /// <inheritdoc/>
            public override void UpdateContents(int index, ConsoleEntryData data)
            {
                if (index != sSelectedElementIdx)
                {
                    if (index % 2 != 0)
                    {
                        background.Visible = true;
                        background.SetTint(BG_COLOR);
                    }
                    else
                    {
                        background.Visible = false;
                    }
                }
                else
                {
                    background.Visible = true;
                    background.SetTint(SELECTION_COLOR);
                }

                switch (data.type)
                {
                case DebugMessageType.Info:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Info, 32, false));
                    break;

                case DebugMessageType.Warning:
                case DebugMessageType.CompilerWarning:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Warning, 32, false));
                    break;

                case DebugMessageType.Error:
                case DebugMessageType.CompilerError:
                    icon.SetTexture(EditorBuiltin.GetLogMessageIcon(LogMessageIcon.Error, 32, false));
                    break;
                }

                messageLabel.SetContent(new LocEdString(data.message));

                string method = "";

                if (data.callstack != null && data.callstack.Length > 0)
                {
                    string filePath        = data.callstack[0].file;
                    bool   isFilePathValid = filePath.IndexOfAny(Path.GetInvalidPathChars()) == -1;

                    if (isFilePathValid)
                    {
                        file = Path.GetFileName(data.callstack[0].file);
                    }
                    else
                    {
                        file = "<unknown file>";
                    }

                    line = data.callstack[0].line;

                    if (string.IsNullOrEmpty(data.callstack[0].method))
                    {
                        method = "\tin " + file + ":" + line;
                    }
                    else
                    {
                        method = "\t" + data.callstack[0].method + " in " + file + ":" + line;
                    }
                }
                else
                {
                    file = "";
                    line = 0;
                }

                functionLabel.SetContent(new LocEdString(method));

                entryIdx = index;
            }