/// <summary>
        /// 绘制控制台
        /// 注意:该接口必须在OnGUI函数内调用
        /// </summary>
        public static void Draw()
        {
            // 注意:GUI接口只能在OnGUI内部使用
            ConsoleGUI.InitGlobalStyle();

            // 整体偏移
            if (OffsetPixels > 0)
            {
                GUILayout.Space(OffsetPixels);
            }

            if (_visibleToggle == false)
            {
                // 显示开关
                if (GUILayout.Button("X", ConsoleGUI.ButtonStyle, GUILayout.Width(ConsoleGUI.ButtonStyle.fixedHeight)))
                {
                    _visibleToggle = !_visibleToggle;
                }
                return;
            }

            GUILayout.BeginHorizontal();
            {
                // 绘制背景
                if (_visibleToggle && _bgTexture != null)
                {
                    GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), _bgTexture, ScaleMode.StretchToFill, true);
                }

                // 显示开关
                if (GUILayout.Button("X", ConsoleGUI.ButtonStyle, GUILayout.Width(ConsoleGUI.ButtonStyle.fixedHeight)))
                {
                    _visibleToggle = !_visibleToggle;
                }

                // 绘制按钮栏
                _showIndex = GUILayout.Toolbar(_showIndex, _toolbarTitles, ConsoleGUI.ToolbarStyle);
            }
            GUILayout.EndHorizontal();

            // 绘制选中窗口
            for (int i = 0; i < _wrappers.Count; i++)
            {
                if (_showIndex != i)
                {
                    continue;
                }
                WindowWrapper wrapper = _wrappers[i];
                wrapper.Instance.OnGUI();
            }
        }
        /// <summary>
        /// 绘制控制台
        /// 注意:该接口必须在OnGUI函数内调用
        /// </summary>
        public static void Draw()
        {
            if (_fpsCounter != null)
            {
                if (_lastFrame != Time.frameCount)
                {
                    _lastFrame = Time.frameCount;
                    _fpsCounter.Update();
                }
            }

            // 注意:GUI接口只能在OnGUI内部使用
            ConsoleGUI.InitGlobalStyle();

            float posX = Screen.safeArea.x;
            float posY = Screen.height - Screen.safeArea.height - Screen.safeArea.y;

            if (_visible == false)
            {
                float wdith  = ConsoleGUI.XStyle.fixedWidth;
                float height = ConsoleGUI.XStyle.fixedHeight;

                // 显示按钮
                if (GUI.Button(new Rect(posX + 10, posY + 10, wdith, height), "X", ConsoleGUI.XStyle))
                {
                    _visible = true;
                }

                // FPS
                if (_fpsCounter != null)
                {
                    int    fps  = _fpsCounter.GetFPS();
                    string text = $"<size={ConsoleGUI.RichLabelFontSize * 2}><color=red>{fps}</color></size>";
                    GUI.Label(new Rect(posX + wdith * 1.5f, posY + 5, wdith * 2, height * 2), text, ConsoleGUI.RichLabelStyle);
                }
            }
            else
            {
                Rect windowRect = new Rect(posX, posY, Screen.safeArea.width, Screen.safeArea.height);
                GUI.Window(0, windowRect, DrawWindow, string.Empty);
            }
        }
示例#3
0
        /// <summary>
        /// 绘制控制台
        /// 注意:该接口必须在OnGUI函数内调用
        /// </summary>
        public static void Draw()
        {
            // 注意:GUI接口只能在OnGUI内部使用
            ConsoleGUI.InitGlobalStyle();

            float posX = Screen.safeArea.x;
            float posY = Screen.height - Screen.safeArea.height - Screen.safeArea.y;

            if (_visible == false)
            {
                // 显示按钮
                if (GUI.Button(new Rect(posX + 10, posY + 10, ConsoleGUI.XStyle.fixedWidth, ConsoleGUI.XStyle.fixedHeight), "X", ConsoleGUI.XStyle))
                {
                    _visible = true;
                }
            }
            else
            {
                Rect windowRect = new Rect(posX, posY, Screen.safeArea.width, Screen.safeArea.height);
                GUI.Window(0, windowRect, DrawWindow, string.Empty);
            }
        }