private static void DisableFrameDebugger()
        {
            // if it was true before, we disabled and ask the game scene to repaint
            if (FrameDebugger.IsLocalEnabled())
            {
                EditorApplication.SetSceneRepaintDirty();
            }

            FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID());
        }
        internal void ClickEnableFrameDebugger()
        {
            bool isEnabled       = FrameDebugger.enabled;
            bool enablingLocally = !isEnabled && m_AttachToPlayerState.connectedToTarget == ConnectionTarget.Editor;

            if (enablingLocally && !FrameDebuggerUtility.locallySupported)
            {
                return;
            }

            // pause play mode if needed
            if (enablingLocally)
            {
                if (EditorApplication.isPlaying && !EditorApplication.isPaused)
                {
                    EditorApplication.isPaused = true;
                }
            }

            if (!isEnabled)
            {
                FrameDebuggerUtility.SetEnabled(true, ProfilerDriver.connectedProfiler);
            }
            else
            {
                FrameDebuggerUtility.SetEnabled(false, FrameDebuggerUtility.GetRemotePlayerGUID());
            }

            // Make sure game view is visible when enabling frame debugger locally
            if (FrameDebugger.IsLocalEnabled())
            {
                PlayModeView playModeView = PlayModeView.GetMainPlayModeView();
                if (playModeView)
                {
                    playModeView.ShowTab();
                }
            }
        }
        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;
            }
        }