예제 #1
0
        void CellGUI(Rect cellRect, ProfileTreeViewItem item, MyColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            switch (column)
            {
            case MyColumns.Name:
            {
                args.rowRect = cellRect;
                base.RowGUI(args);
            }
            break;

            case MyColumns.Average:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msFrameAverage));
                break;

            case MyColumns.Depth:
                if (m_profileAnalyserWindow.GetDepthFilter() >= 0 || item.data.minDepth == item.data.maxDepth)
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0}", item.data.minDepth));
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0}-{1}", item.data.minDepth, item.data.maxDepth));
                }
                break;

            case MyColumns.Median:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msMedian));
                break;

            case MyColumns.MedianBar:
            {
                float ms = item.data.msMedian;
                if (ms > 0.0f)
                {
                    if (m_profileAnalyserWindow.DrawStart(cellRect))
                    {
                        float w = cellRect.width * ms / m_maxMedian;
                        m_profileAnalyserWindow.DrawBar(0, 1, w, cellRect.height - 1, m_profileAnalyserWindow.m_colorBar);
                        m_profileAnalyserWindow.DrawEnd();
                    }
                }
                GUI.Label(cellRect, new GUIContent("", string.Format("{0:f2}", item.data.msMedian)));
            }
            break;

            case MyColumns.Min:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msMin));
                break;

            case MyColumns.Max:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msMax));
                break;

            case MyColumns.Range:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msMax - item.data.msMin));
                break;

            case MyColumns.Count:
                EditorGUI.LabelField(cellRect, string.Format("{0}", item.data.count));
                break;

            case MyColumns.CountAverage:
                EditorGUI.LabelField(cellRect, string.Format("{0}", item.data.count / m_model.GetFrameSummary().count));
                break;

            case MyColumns.FirstFrame:
                if (!m_profileAnalyserWindow.IsProfilerWindowOpen())
                {
                    GUI.enabled = false;
                }
                if (GUI.Button(cellRect, new GUIContent(item.data.firstFrameIndex.ToString())))
                {
                    m_profileAnalyserWindow.SelectMarker(item.id);
                    m_profileAnalyserWindow.JumpToFrame(item.data.firstFrameIndex);
                }

                GUI.enabled = true;
                break;

            case MyColumns.AtMedian:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", item.data.msAtMedian));
                break;
            }
        }
예제 #2
0
        void CellGUI(Rect cellRect, ComparisonTreeViewItem item, MyColumns column, ref RowGUIArgs args)
        {
            // Center cell rect vertically (makes it easier to place controls, icons etc in the cells)
            CenterRectUsingSingleLineHeight(ref cellRect);

            // Find largest of min/max and use that range and both the -ve and +ve extends for the bar graphs.
            float min   = Math.Abs(m_minDiff);
            float max   = Math.Abs(m_maxDiff);
            float range = Math.Max(min, max);

            switch (column)
            {
            case MyColumns.Name:
            {
                args.rowRect = cellRect;
                base.RowGUI(args);
            }
            break;

            case MyColumns.LeftMedian:
                if (item.data.leftIndex < 0)
                {
                    EditorGUI.LabelField(cellRect, "-");
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0:f2}", LeftMedian(item)));
                }
                break;

            case MyColumns.Left:
            {
                float diff = Diff(item);
                if (diff < 0.0f)
                {
                    if (m_profileAnalyserWindow.DrawStart(cellRect))
                    {
                        float w = cellRect.width * -diff / range;
                        m_profileAnalyserWindow.DrawBar(cellRect.width - w, 1, w, cellRect.height - 1, m_profileAnalyserWindow.m_colorLeft);
                        m_profileAnalyserWindow.DrawEnd();
                    }
                }
                GUI.Label(cellRect, new GUIContent("", string.Format("{0:f2}", Diff(item))));
            }
            break;

            case MyColumns.Diff:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", Diff(item)));
                break;

            case MyColumns.Right:
            {
                float diff = Diff(item);
                if (diff > 0.0f)
                {
                    if (m_profileAnalyserWindow.DrawStart(cellRect))
                    {
                        float w = cellRect.width * diff / range;
                        m_profileAnalyserWindow.DrawBar(0, 1, w, cellRect.height - 1, m_profileAnalyserWindow.m_colorRight);
                        m_profileAnalyserWindow.DrawEnd();
                    }
                }
                GUI.Label(cellRect, new GUIContent("", string.Format("{0:f2}", Diff(item))));
            }
            break;

            case MyColumns.RightMedian:
                if (item.data.rightIndex < 0)
                {
                    EditorGUI.LabelField(cellRect, "-");
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0:f2}", RightMedian(item)));
                }
                break;

            case MyColumns.AbsDiff:
                EditorGUI.LabelField(cellRect, string.Format("{0:f2}", AbsDiff(item)));
                break;

            case MyColumns.LeftCount:
                if (item.data.leftIndex < 0)
                {
                    EditorGUI.LabelField(cellRect, "-");
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0}", LeftCount(item)));
                }
                break;

            case MyColumns.RightCount:
                if (item.data.rightIndex < 0)
                {
                    EditorGUI.LabelField(cellRect, "-");
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0}", RightCount(item)));
                }
                break;

            case MyColumns.CountDiff:
                if (item.data.leftIndex < 0 && item.data.rightIndex < 0)
                {
                    EditorGUI.LabelField(cellRect, "-");
                }
                else
                {
                    EditorGUI.LabelField(cellRect, string.Format("{0}", CountDiff(item)));
                }
                break;
            }
        }