Пример #1
0
 public static void StackTraceButton(StackTrace stackTrace)
 {
     if (GUILayout.Button("Stack trace", GUILayout.ExpandWidth(false)))
     {
         var viewer = StackTraceViewer.CreateStackTraceViewer(stackTrace);
         var mouse  = Input.mousePosition;
         mouse.y = Screen.height - mouse.y;
         viewer.rect.position = mouse;
         viewer.visible       = true;
     }
 }
Пример #2
0
        void DrawConsole()
        {
            userNotifications = UserNotifications.GetNotifications();

            consoleArea.Begin();

            consoleScrollPosition = GUILayout.BeginScrollView(consoleScrollPosition);

            foreach (var item in userNotifications)
            {
                GUILayout.BeginHorizontal(skin.box);

                GUI.contentColor = Color.blue;
                GUILayout.Label(item.Value);
                GUI.contentColor = Color.white;

                if (GUILayout.Button("Hide"))
                {
                    UserNotifications.HideNotification(item.Key);
                }

                GUILayout.EndHorizontal();
            }

            ConsoleMessage[] messages = null;

            lock (historyLock)
            {
                messages = history.ToArray();
            }

            foreach (ConsoleMessage item in messages)
            {
                GUILayout.BeginHorizontal(skin.box);

                string msg = config.consoleFormatString.Replace("{{type}}", item.type.ToString())
                             .Replace("{{caller}}", item.caller)
                             .Replace("{{message}}", item.message);

                switch (item.type)
                {
                case LogType.Log:
                    GUI.contentColor = config.consoleMessageColor;
                    break;

                case LogType.Warning:
                    GUI.contentColor = config.consoleWarningColor;
                    break;

                case LogType.Error:
                    GUI.contentColor = config.consoleErrorColor;
                    break;

                case LogType.Assert:
                case LogType.Exception:
                    GUI.contentColor = config.consoleExceptionColor;
                    break;
                }

                GUILayout.Label(msg);

                GUILayout.FlexibleSpace();

                if (item.count > 1)
                {
                    GUI.contentColor = orangeColor;
                    if (item.count > 1024)
                    {
                        GUI.contentColor = Color.red;
                    }

                    GUILayout.Label(item.count.ToString(), skin.box);
                }
                else
                {
                    GUILayout.Label("");
                }

                GUI.contentColor = Color.white;

                if (item.trace != null)
                {
                    if (GUILayout.Button("Stack trace", GUILayout.ExpandWidth(false)))
                    {
                        var viewer = StackTraceViewer.CreateStackTraceViewer(item.trace);
                        var mouse  = Input.mousePosition;
                        mouse.y = Screen.height - mouse.y;
                        viewer.rect.position = mouse;
                        viewer.visible       = true;
                    }
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            consoleArea.End();
        }