Exemplo n.º 1
0
    void OnGUI()
    {
        if (!this.showGUI)
        {
            return;
        }

        if (this.onGUICallback != null)
        {
            this.onGUICallback();
        }

        if (GUI.Button(new Rect(20, 20, 60, 30), ShowConsole.Instance().references.itsOnOff, GUIStyle.none))
        {
            if (showLogWindow)
            {
                showLogWindow = false;
            }
            else
            {
                showLogWindow = true;
            }
            //PlayerPrefs.DeleteAll();
            //#if UNITY_EDITOR
            //            EditorApplication.isPlaying = false;
            //#else
            //            Application.Quit();
            //#endif
        }
        if (showLogWindow)
        {
            windowRect = GUILayout.Window(123456, windowRect, ConsoleWindow, "Console");
        }
    }
Exemplo n.º 2
0
    private ConsoleDisplay()
    {
        this.fpsCounter     = new FPSCounter(this);
        this.memoryDetector = new MemoryDetector(this);
        //this.showGUI = App.Instance().showLogOnGUI;

        ShowConsole.Instance().onUpdate += Update;
        ShowConsole.Instance().onGUI    += OnGUI;
        //Application.logMessageReceived += HandleLog;
    }
Exemplo n.º 3
0
    /// <summary>
    /// A window displaying the logged messages.
    /// </summary>
    void ConsoleWindow(int windowID)
    {
        if (scrollToBottom)
        {
            GUILayout.BeginScrollView(Vector2.up * entries.Count * 100.0f);
        }
        else
        {
            scrollPos = GUILayout.BeginScrollView(scrollPos);
        }
        // Go through each logged entry
        int curMax = ((currentPage + 1) * numMax) < entries.Count ? (int)((currentPage + 1) * numMax) : entries.Count;

        for (int i = (int)(currentPage * numMax); i < curMax; i++)
        {
            ConsoleMessage entry = entries[i];
            // If this message is the same as the last one and the collapse feature is chosen, skip it
            if (collapse && i > 0 && entry.message == entries[i - 1].message)
            {
                continue;
            }
            if (!showError && entry.type == LogType.Error)
            {
                continue;
            }
            if (!showWarning && entry.type == LogType.Warning)
            {
                continue;
            }
            if (!showLog && entry.type == LogType.Log)
            {
                continue;
            }


            // Change the text colour according to the log type
            switch (entry.type)
            {
            case LogType.Error:
            case LogType.Exception:
                GUI.contentColor = Color.red;
                break;

            case LogType.Warning:
                GUI.contentColor = Color.yellow;
                break;

            default:
                GUI.contentColor = Color.white;
                break;
            }
            if (entry.type == LogType.Exception)
            {
                GUILayout.Label(entry.message + "  || " + entry.stackTrace);
            }
            else if (showDetail)
            {
                GUILayout.Label(entry.message + "     ||     " + entry.stackTrace);
            }
            else
            {
                GUILayout.Label(entry.message);
            }
        }
        GUI.contentColor = Color.white;
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        // Clear button
        if (GUILayout.Button(clearLabel))
        {
            entries.Clear();
            currentPage = 0;
        }

        showError   = GUILayout.Toggle(showError, errorLabel, GUILayout.ExpandWidth(false));
        showWarning = GUILayout.Toggle(showWarning, warningLabel, GUILayout.ExpandWidth(false));
        showLog     = GUILayout.Toggle(showLog, logLabel, GUILayout.ExpandWidth(false));

        // Collapse toggle
        collapse       = GUILayout.Toggle(collapse, collapseLabel, GUILayout.ExpandWidth(false));
        scrollToBottom = GUILayout.Toggle(scrollToBottom, scrollToBottomLabel, GUILayout.ExpandWidth(false));

        showDetail = GUILayout.Toggle(showDetail, detailLabel, GUILayout.ExpandWidth(true));

        if (GUILayout.Button(ShowConsole.Instance().references.itsIconLeft) && currentPage > 0)
        {
            currentPage--;
        }
        GUILayout.Box(PageTip());

        if (GUILayout.Button(ShowConsole.Instance().references.itsIconRight) && currentPage < itsNumberOfPages - 1)
        {
            currentPage++;
        }

        GUILayout.EndHorizontal();
        // Set the window to be draggable by the top title bar
        GUI.DragWindow(new Rect(0, 0, 10000, 20));

        //GUILayout.Button(
        //GUILayout.Toggle
    }