示例#1
0
        public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection)
        {
            if (frameDataView == null || !frameDataView.valid || selection.Count == 0)
            {
                DrawEmptyPane(headerStyle);
                return;
            }

            InitIfNeeded();
            UpdateIfNeeded(frameDataView, selection[0]);

            var selectedSampleId            = m_TreeView.GetSelectedFrameDataViewId();
            var selectedMergedSampleIndex   = m_TreeView.GetSelectedFrameDataViewMergedSampleIndex();
            var selectedSampleMetadataCount = 0;

            if (selectedSampleId != -1)
            {
                frameDataView.GetItemMergedSampleCallstack(selectedSampleId, selectedMergedSampleIndex, m_CachedCallstack);
                selectedSampleMetadataCount = frameDataView.GetItemMergedSamplesMetadataCount(selectedSampleId, selectedMergedSampleIndex);
            }

            var showCallstack = m_CachedCallstack.Count > 0;
            var showMetadata  = selectedSampleMetadataCount != 0;

            SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea);

            // Detailed list
            var rect = EditorGUILayout.BeginVertical(Styles.expandedArea);

            m_TreeView.OnGUI(rect);

            EditorGUILayout.EndVertical();

            // Callstack area
            EditorGUILayout.BeginVertical(Styles.expandedArea);

            // Display active text (We want word wrapped text with a vertical scrollbar)
            m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll);

            var sb = new StringBuilder();

            if (showMetadata || showCallstack)
            {
                if (showMetadata)
                {
                    var metadataInfo = frameDataView.GetMarkerMetadataInfo(frameDataView.GetItemMarkerID(selectedSampleId));

                    sb.Append(kMetadataText);
                    sb.Append('\n');
                    for (var i = 0; i < selectedSampleMetadataCount; ++i)
                    {
                        if (metadataInfo != null && i < metadataInfo.Length)
                        {
                            sb.Append(metadataInfo[i].name);
                        }
                        else
                        {
                            sb.Append(i);
                        }
                        sb.Append(": ");
                        sb.Append(frameDataView.GetItemMergedSamplesMetadata(selectedSampleId, selectedMergedSampleIndex, i));
                        sb.Append('\n');
                    }
                    sb.Append('\n');
                }

                if (showCallstack)
                {
                    sb.Append(kCallstackText);
                    sb.Append('\n');
                    foreach (var addr in m_CachedCallstack)
                    {
                        var methodInfo = frameDataView.ResolveMethodInfo(addr);
                        if (string.IsNullOrEmpty(methodInfo.methodName))
                        {
                            sb.AppendFormat("0x{0:X}\n", addr);
                        }
                        else if (string.IsNullOrEmpty(methodInfo.sourceFileName))
                        {
                            sb.AppendFormat("0x{0:X}\t\t{1}\n", addr, methodInfo.methodName);
                        }
                        else
                        {
                            var normalizedPath = methodInfo.sourceFileName.Replace('\\', '/');
                            if (methodInfo.sourceFileLine == 0)
                            {
                                sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"1\">{2}</a>\n", addr, methodInfo.methodName, normalizedPath);
                            }
                            else
                            {
                                sb.AppendFormat("0x{0:X}\t\t{1}\t<a href=\"{2}\" line=\"{3}\">{2}:{3}</a>\n", addr, methodInfo.methodName, normalizedPath, methodInfo.sourceFileLine);
                            }
                        }
                    }
                }
            }
            else
            {
                sb.Append(kNoMetadataOrCallstackText);
            }

            var metadataText = sb.ToString();

            Styles.callstackTextArea.CalcMinMaxWidth(GUIContent.Temp(metadataText), out _, out var maxWidth);
            float minHeight = Styles.callstackTextArea.CalcHeight(GUIContent.Temp(metadataText), maxWidth);

            EditorGUILayout.SelectableLabel(metadataText, Styles.callstackTextArea, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true), GUILayout.MinWidth(maxWidth + 10), GUILayout.MinHeight(minHeight + 10));

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();

            SplitterGUILayout.EndVerticalSplit();
        }
示例#2
0
        public void DoGUI(GUIStyle headerStyle, HierarchyFrameDataView frameDataView, IList <int> selection)
        {
            if (frameDataView == null || !frameDataView.valid || selection.Count == 0)
            {
                DrawEmptyPane(headerStyle);
                return;
            }

            InitIfNeeded();
            UpdateIfNeeded(frameDataView, selection[0]);

            var selectedSampleId = m_TreeView.GetSelectedFrameDataViewId();

            if (selectedSampleId != -1)
            {
                frameDataView.GetItemMergedSampleCallstack(selectedSampleId, m_TreeView.state.selectedIDs[0], m_CachedCallstack);
            }

            var showCallstack = m_CachedCallstack.Count > 0;

            if (showCallstack)
            {
                SplitterGUILayout.BeginVerticalSplit(m_VertSplit, Styles.expandedArea);
            }

            // Detailed list
            var rect = EditorGUILayout.BeginVertical(Styles.expandedArea);

            m_TreeView.OnGUI(rect);

            EditorGUILayout.EndVertical();

            if (showCallstack)
            {
                // Callstack area
                EditorGUILayout.BeginVertical(Styles.expandedArea);
                m_CallstackScrollViewPos = EditorGUILayout.BeginScrollView(m_CallstackScrollViewPos, Styles.callstackScroll);

                var sb = new StringBuilder(kCallstackText + '\n');
                foreach (var addr in m_CachedCallstack)
                {
                    var methodInfo = frameDataView.ResolveMethodInfo(addr);
                    if (string.IsNullOrEmpty(methodInfo.methodName))
                    {
                        sb.AppendFormat("0x{0:X}\n", addr);
                    }
                    else if (string.IsNullOrEmpty(methodInfo.sourceFileName))
                    {
                        sb.AppendFormat("0x{0:X}\t{1}\n", addr, methodInfo.methodName);
                    }
                    else if (methodInfo.sourceFileLine == 0)
                    {
                        sb.AppendFormat("0x{0:X}\t{1}\t{2}\n", addr, methodInfo.methodName, methodInfo.sourceFileName);
                    }
                    else
                    {
                        sb.AppendFormat("0x{0:X}\t{1}\t{2}:{3}\n", addr, methodInfo.methodName, methodInfo.sourceFileName, methodInfo.sourceFileLine);
                    }
                }
                EditorGUILayout.TextArea(sb.ToString(), Styles.callstackTextArea);

                EditorGUILayout.EndScrollView();
                EditorGUILayout.EndVertical();

                SplitterGUILayout.EndVerticalSplit();
            }
        }