internal void DrawUIPane(ProfilerWindow win, ProfilerArea profilerArea, UISystemProfilerChart detailsChart)
        {
            InitIfNeeded(win);

            EditorGUILayout.BeginVertical();

            if (m_DetachedPreview != null && !m_DetachedPreview)
            {
                m_DetachedPreview = null;
            }
            bool detachPreview = m_DetachedPreview;

            if (!detachPreview)
            {
                GUILayout.BeginHorizontal(); // Horizontal render
                SplitterGUILayout.BeginHorizontalSplit(m_TreePreviewHorizontalSplitState);
            }

            var treeRect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

            treeRect.yMin -= EditorGUIUtility.standardVerticalSpacing;
            m_TreeViewControl.property = win.CreateProperty();

            if (!m_TreeViewControl.property.frameDataReady)
            {
                m_TreeViewControl.property.Cleanup();
                m_TreeViewControl.property = null;
                GUI.Label(treeRect, Styles.noData);
            }
            else
            {
                var newVisibleFrame = win.GetActiveVisibleFrameIndex();
                if (m_UGUIProfilerTreeViewState != null && m_UGUIProfilerTreeViewState.lastFrame != newVisibleFrame)
                {
                    currentFrame = ProfilerDriver.lastFrameIndex - newVisibleFrame;

                    m_TreeViewControl.Reload();
                }
                m_TreeViewControl.OnGUI(treeRect);
                m_TreeViewControl.property.Cleanup();
            }

            if (!detachPreview)
            {
                using (new EditorGUILayout.VerticalScope())
                {
                    using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, GUILayout.ExpandWidth(true)))
                    {
                        detachPreview = GUILayout.Button(Styles.contentDetachRender, EditorStyles.toolbarButton, GUILayout.Width(75));
                        if (detachPreview)
                        {
                            m_DetachedPreview          = EditorWindow.GetWindow <UISystemPreviewWindow>();
                            m_DetachedPreview.profiler = this;
                            m_DetachedPreview.Show();
                        }
                        DrawPreviewToolbarButtons();
                    }
                    DrawRenderUI();
                }

                GUILayout.EndHorizontal();              // Horizontal render
                SplitterGUILayout.EndHorizontalSplit(); // m_TreePreviewHorizontalSplitState

                // Draw separator
                EditorGUI.DrawRect(
                    new Rect(m_TreePreviewHorizontalSplitState.realSizes[0] + treeRect.xMin, treeRect.y, 1, treeRect.height),
                    Styles.separatorColor);
            }

            EditorGUILayout.EndVertical();

            if (m_DetachedPreview)
            {
                m_DetachedPreview.Repaint();
            }
        }
        private void InitIfNeeded(ProfilerWindow win)
        {
            if (m_ZoomablePreview != null)
            {
                return;
            }

            m_ZoomablePreview = new ZoomableArea(true, false)
            {
                hRangeMin = 0.0f,
                vRangeMin = 0.0f,
                hRangeMax = 1.0f,
                vRangeMax = 1.0f
            };

            m_ZoomablePreview.SetShownHRange(0, 1);
            m_ZoomablePreview.SetShownVRange(0, 1);

            m_ZoomablePreview.uniformScale    = true;
            m_ZoomablePreview.scaleWithWindow = true;

            var initwidth = 100;
            var maxWidth  = 200;

            m_MulticolumnHeaderState = new MultiColumnHeaderState(new[]
            {
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Object"), width = 220, maxWidth = 400, canSort = true
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Self Batch Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Cumulative Batch Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Self Vertex Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("Cumulative Vertex Count"), width = initwidth, maxWidth = maxWidth
                },
                new MultiColumnHeaderState.Column
                {
                    headerContent = EditorGUIUtility.TrTextContent("Batch Breaking Reason"),
                    width         = 220,
                    maxWidth      = 400,
                    canSort       = false
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("GameObject Count"), width = initwidth, maxWidth = 400
                },
                new MultiColumnHeaderState.Column {
                    headerContent = EditorGUIUtility.TrTextContent("GameObjects"), width = 150, maxWidth = 400, canSort = false
                },
            });
            foreach (var column in m_MulticolumnHeaderState.columns)
            {
                column.sortingArrowAlignment = TextAlignment.Right;
            }

            m_UGUIProfilerTreeViewState = new UISystemProfilerTreeView.State {
                profilerWindow = win
            };
            var multiColumnHeader = new Headers(m_MulticolumnHeaderState)
            {
                canSort = true, height = 21
            };

            multiColumnHeader.sortingChanged += header => { m_TreeViewControl.Reload(); };
            m_TreeViewControl = new UISystemProfilerTreeView(m_UGUIProfilerTreeViewState, multiColumnHeader);
            m_TreeViewControl.Reload();
        }