Exemplo n.º 1
0
        internal void OnGUI()
        {
            if (!FrameDebuggerWindow.ShowFrameDebuggerWindowValidate())
            {
                EditorGUILayout.HelpBox("Frame Debugger requires a Pro license", MessageType.Warning, true);
                return;
            }
            FrameDebuggerEvent[] frameEvents = FrameDebuggerUtility.GetFrameEvents();
            if (this.m_TreeViewState == null)
            {
                this.m_TreeViewState = new TreeViewState();
            }
            if (this.m_Tree == null)
            {
                this.m_Tree            = new FrameDebuggerTreeView(frameEvents, this.m_TreeViewState, this, default(Rect));
                this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
                this.m_Tree.m_DataSource.SetExpandedWithChildren(this.m_Tree.m_DataSource.root, true);
            }
            if (FrameDebuggerUtility.eventsHash != this.m_FrameEventsHash)
            {
                this.m_Tree.m_DataSource.SetEvents(frameEvents);
                this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
            }
            int  limit = FrameDebuggerUtility.limit;
            bool flag  = this.DrawToolbar(frameEvents);

            if (!FrameDebuggerUtility.enabled)
            {
                GUI.enabled = true;
                if (!FrameDebuggerWindow.GraphicsSupportsFrameDebugger())
                {
                    EditorGUILayout.HelpBox("Frame Debugger requires multi-threaded renderer. Usually Unity uses that; if it does not try starting with -force-gfx-mt command line argument.", MessageType.Warning, true);
                }
                EditorGUILayout.HelpBox("Frame Debugger lets you step through draw calls and see how exactly frame is rendered. Click Enable!", MessageType.Info, true);
            }
            else
            {
                float fixedHeight = EditorStyles.toolbar.fixedHeight;
                Rect  dragRect    = new Rect(this.m_ListWidth, fixedHeight, 5f, base.position.height - fixedHeight);
                dragRect         = EditorGUIUtility.HandleHorizontalSplitter(dragRect, base.position.width, 200f, 200f);
                this.m_ListWidth = dragRect.x;
                Rect rect  = new Rect(0f, fixedHeight, this.m_ListWidth, base.position.height - fixedHeight);
                Rect rect2 = new Rect(this.m_ListWidth + 4f, fixedHeight + 4f, base.position.width - this.m_ListWidth - 8f, base.position.height - fixedHeight - 8f);
                this.DrawEventsTree(rect);
                EditorGUIUtility.DrawHorizontalSplitter(dragRect);
                this.DrawCurrentEvent(rect2, frameEvents);
            }
            if (flag || limit != FrameDebuggerUtility.limit)
            {
                this.RepaintOnLimitChange();
            }
            if (this.m_RepaintFrames > 0)
            {
                this.m_Tree.SelectFrameEventIndex(FrameDebuggerUtility.limit);
                this.RepaintAllNeededThings();
                this.m_RepaintFrames--;
            }
        }
Exemplo n.º 2
0
        internal void OnGUI()
        {
            FrameDebuggerEvent[] frameEvents = FrameDebuggerUtility.GetFrameEvents();
            if (this.m_TreeViewState == null)
            {
                this.m_TreeViewState = new TreeViewState();
            }
            if (this.m_Tree == null)
            {
                this.m_Tree            = new FrameDebuggerTreeView(frameEvents, this.m_TreeViewState, this, new Rect());
                this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
                this.m_Tree.m_DataSource.SetExpandedWithChildren(this.m_Tree.m_DataSource.root, true);
            }
            if (FrameDebuggerUtility.eventsHash != this.m_FrameEventsHash)
            {
                this.m_Tree.m_DataSource.SetEvents(frameEvents);
                this.m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
            }
            int  limit = FrameDebuggerUtility.limit;
            bool flag  = this.DrawToolbar(frameEvents);

            if (!FrameDebuggerUtility.IsLocalEnabled() && !FrameDebuggerUtility.IsRemoteEnabled() && this.m_AttachProfilerUI.IsEditor())
            {
                GUI.enabled = true;
                if (!FrameDebuggerUtility.locallySupported)
                {
                    EditorGUILayout.HelpBox("Frame Debugger requires multi-threaded renderer. Usually Unity uses that; if it does not, try starting with -force-gfx-mt command line argument.", MessageType.Warning, true);
                }
                EditorGUILayout.HelpBox("Frame Debugger lets you step through draw calls and see how exactly frame is rendered. Click Enable!", MessageType.Info, true);
            }
            else
            {
                float fixedHeight = EditorStyles.toolbar.fixedHeight;
                Rect  dragRect    = EditorGUIUtility.HandleHorizontalSplitter(new Rect(this.m_ListWidth, fixedHeight, 5f, this.position.height - fixedHeight), this.position.width, 200f, 200f);
                this.m_ListWidth = dragRect.x;
                Rect rect1 = new Rect(0.0f, fixedHeight, this.m_ListWidth, this.position.height - fixedHeight);
                Rect rect2 = new Rect(this.m_ListWidth + 4f, fixedHeight + 4f, (float)((double)this.position.width - (double)this.m_ListWidth - 8.0), (float)((double)this.position.height - (double)fixedHeight - 8.0));
                this.DrawEventsTree(rect1);
                EditorGUIUtility.DrawHorizontalSplitter(dragRect);
                this.DrawCurrentEvent(rect2, frameEvents);
            }
            if (flag || limit != FrameDebuggerUtility.limit)
            {
                this.RepaintOnLimitChange();
            }
            if (this.m_RepaintFrames <= 0)
            {
                return;
            }
            this.m_Tree.SelectFrameEventIndex(FrameDebuggerUtility.limit);
            this.RepaintAllNeededThings();
            --this.m_RepaintFrames;
        }
Exemplo n.º 3
0
        private void OnGUI()
        {
            FrameDebuggerEvent[] descs = FrameDebuggerUtility.GetFrameEvents();
            Initialize(descs);

            int oldLimit = FrameDebuggerUtility.limit;

            Profiler.BeginSample("DrawToolbar");
            bool repaint = m_Toolbar.DrawToolbar(this, m_AttachToPlayerState);

            Profiler.EndSample();

            if (IsDisabledInEditor)
            {
                GUI.enabled = true;
                if (!FrameDebuggerUtility.locallySupported)
                {
                    string warningMessage = (FrameDebuggerHelper.IsOnLinuxOpenGL) ? FrameDebuggerStyles.EventDetails.warningLinuxOpenGLMsg : FrameDebuggerStyles.EventDetails.warningMultiThreadedMsg;
                    EditorGUILayout.HelpBox(warningMessage, MessageType.Warning, true);
                }

                EditorGUILayout.HelpBox(FrameDebuggerStyles.EventDetails.descriptionString, MessageType.Info, true);
            }
            else
            {
                if (FrameDebugger.IsLocalEnabled())
                {
                    PlayModeView playModeView = PlayModeView.GetMainPlayModeView();
                    if (playModeView)
                    {
                        playModeView.ShowTab();
                    }
                }

                // captured frame event contents have changed, rebuild the tree data
                if (HasEventHashChanged)
                {
                    m_TreeView.m_DataSource.SetEvents(descs);
                    m_FrameEventsHash = FrameDebuggerUtility.eventsHash;
                }

                float toolbarHeight = EditorStyles.toolbar.fixedHeight;

                Rect dragRect = new Rect(m_TreeWidth, toolbarHeight, FrameDebuggerStyles.Window.k_ResizerWidth, position.height - toolbarHeight);
                dragRect    = EditorGUIUtility.HandleHorizontalSplitter(dragRect, position.width, FrameDebuggerStyles.Window.k_MinTreeWidth, FrameDebuggerStyles.Window.k_MinDetailsWidth);
                m_TreeWidth = dragRect.x;

                // Search area
                m_SearchRect       = EditorGUILayout.GetControlRect();
                m_SearchRect.width = m_TreeWidth - 5;
                DrawSearchField(m_SearchString);

                Rect listRect = new Rect(
                    0,
                    toolbarHeight + m_SearchRect.y,
                    m_TreeWidth,
                    position.height - toolbarHeight - m_SearchRect.height - 5
                    );

                Rect currentEventRect = new Rect(
                    m_TreeWidth,
                    toolbarHeight,
                    position.width - m_TreeWidth,
                    position.height - toolbarHeight
                    );

                Profiler.BeginSample("DrawTree");
                m_TreeView.m_TreeView.searchString = m_SearchString;
                m_TreeView.DrawTree(listRect);
                Profiler.EndSample();

                EditorGUIUtility.DrawHorizontalSplitter(dragRect);

                Profiler.BeginSample("DrawEvent");
                m_EventDetailsView.DrawEvent(currentEventRect, descs, m_AttachToPlayerState.connectedToTarget == ConnectionTarget.Editor);
                Profiler.EndSample();
            }

            if (repaint || oldLimit != FrameDebuggerUtility.limit)
            {
                RepaintOnLimitChange();
            }

            if (m_RepaintFrames > 0)
            {
                m_TreeView.SelectFrameEventIndex(FrameDebuggerUtility.limit);
                RepaintAllNeededThings();
                --m_RepaintFrames;
            }
        }