private void OutputWindow_OnGUI()
        {
            logStyle = SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft, wordWrap: true);

            SNWindow.CreateWindow(OutputWindow_Rect, "Output Window", false, false);

            scrollPos = GUI.BeginScrollView(OutputWindow_scrollRect, scrollPos, new Rect(OutputWindow_scrollRect.x, OutputWindow_scrollRect.y, scrollWidth, drawingPos - OutputWindow_scrollRect.y));

            for (int i = 0; i < logMessage.Count; i++)
            {
                if (i == 0)
                {
                    drawingPos = OutputWindow_scrollRect.y;
                }

                contentHeight = logStyle.CalcHeight(new GUIContent(logMessage[i].message), scrollWidth);

                logStyle.normal.textColor = SNStyles.GetGuiColor(logTypeColors[logMessage[i].type]);

                GUI.Label(new Rect(OutputWindow_scrollRect.x + 5, drawingPos, 15, 21), "> ", logStyle);

                GUI.Label(new Rect(OutputWindow_scrollRect.x + 20, drawingPos, scrollWidth, contentHeight), logMessage[i].message, logStyle);

                drawingPos += contentHeight + 1;
            }

            if (messageCount != logMessage.Count)
            {
                scrollPos.y += Mathf.Infinity;
                messageCount = logMessage.Count;
            }

            GUI.EndScrollView();
        }
예제 #2
0
        void OnGUI()
        {
            if (!show)
            {
                return;
            }

            logStyle = SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft, wordWrap: true);

            SNWindow.CreateWindow(windowRect, $"CheatManager Console (Press {CmConfig.KEYBINDINGS["ToggleConsole"]} to toggle)", true, true);

            scrollPos = GUI.BeginScrollView(scrollRect, scrollPos, new Rect(scrollRect.x, scrollRect.y, scrollWidth, drawingPos - scrollRect.y));

            for (int i = 0; i < logMessage.Count; i++)
            {
                if (i == 0)
                {
                    drawingPos = scrollRect.y;
                }

                contentHeight = logStyle.CalcHeight(new GUIContent(logMessage[i].message), scrollWidth);

                logStyle.normal.textColor = SNStyles.GetGuiColor(logTypeColors[logMessage[i].type]);

                GUI.Label(new Rect(scrollRect.x + 5, drawingPos, 15, 21), "> ", logStyle);

                GUI.Label(new Rect(scrollRect.x + 20, drawingPos, scrollWidth, contentHeight), logMessage[i].message, logStyle);

                drawingPos += contentHeight + 1;

                if (logMessage[i].stackTrace != "")
                {
                    contentHeight = logStyle.CalcHeight(new GUIContent(logMessage[i].stackTrace), scrollWidth);

                    logStyle.normal.textColor = SNStyles.GetGuiColor(logTypeColors[logMessage[i].type]);

                    GUI.Label(new Rect(scrollRect.x + 20, drawingPos, scrollWidth, contentHeight), logMessage[i].stackTrace, logStyle);

                    drawingPos += contentHeight + 1;
                }
            }

#if AUTOSCROLL
            if (messageCount != logMessage.Count)
            {
                scrollPos.y += Mathf.Infinity;
                messageCount = logMessage.Count;
            }
#endif
            GUI.EndScrollView();

            if (GUI.Button(buttonRect, "Clear Window"))
            {
                logMessage.Clear();
                drawingPos = scrollRect.y;
            }
        }
        void OnGUI()
        {
            if (!show)
            {
                return;
            }

            logStyle = SNStyles.GetGuiItemStyle(GuiItemType.LABEL, GuiColor.Green, TextAnchor.MiddleLeft, wordWrap: true);

            SNWindow.CreateWindow(windowRect, $"CheatManagerZero Console (Press {CmZConfig.KEYBINDINGS["ToggleConsole"]} to toggle)", true, true);

            scrollPos = GUI.BeginScrollView(scrollRect, scrollPos, new Rect(scrollRect.x, scrollRect.y, scrollWidth, drawingPos - scrollRect.y));

            for (int i = 0; i < logMessage.Count; i++)
            {
                if (i == 0)
                {
                    drawingPos = scrollRect.y;
                }

                contentHeight = logStyle.CalcHeight(new GUIContent(logMessage[i].message), scrollWidth);

                logStyle.normal.textColor = SNStyles.GetGuiColor(logTypeColors[logMessage[i].type]);

                GUI.Label(new Rect(scrollRect.x + 5, drawingPos, 15, 21), "> ", logStyle);
                GUI.Label(new Rect(scrollRect.x + 20, drawingPos, scrollWidth, contentHeight), logMessage[i].message, logStyle);

                drawingPos += contentHeight + 1;

                if (logMessage[i].stackTrace != "")
                {
                    contentHeight             = logStyle.CalcHeight(new GUIContent(logMessage[i].stackTrace), scrollWidth);
                    logStyle.normal.textColor = SNStyles.GetGuiColor(logTypeColors[logMessage[i].type]);
                    GUI.Label(new Rect(scrollRect.x + 20, drawingPos, scrollWidth, contentHeight), logMessage[i].stackTrace, logStyle);
                    drawingPos += contentHeight + 1;
                }
            }

#if AUTOSCROLL
            if (messageCount != logMessage.Count)
            {
                scrollPos.y += Mathf.Infinity;
                messageCount = logMessage.Count;
            }
#endif
            GUI.EndScrollView();

            /*
             * if (Event.current.Equals(Event.KeyboardEvent("return")) && inputField != "")
             * {
             *  history.Add(inputField);
             *  historyIndex = history.Count;
             *  Log(inputField);
             *  DevConsole.SendConsoleCommand(inputField);
             *  inputField = "";
             * }
             *
             * if (Event.current.Equals(Event.KeyboardEvent("up")))
             * {
             *  if (history.Count > 0 && historyIndex >= 1)
             *  {
             *      historyIndex--;
             *      inputField = history[historyIndex];
             *  }
             * }
             *
             * if (Event.current.Equals(Event.KeyboardEvent("down")))
             * {
             *  if (history.Count > 0 && historyIndex < history.Count - 1)
             *  {
             *      historyIndex++;
             *      inputField = history[historyIndex];
             *  }
             * }
             *
             * inputField = GUI.TextField(new Rect(scrollRect.x + 5, scrollRect.y + scrollRect.height + 5, 300, 22), inputField);
             */

            if (GUI.Button(buttonRect, "Clear Window"))
            {
                logMessage.Clear();
                drawingPos = scrollRect.y;
            }
        }