public int GetItemIDFromRawFrameDataViewIndex(HierarchyFrameDataView frameDataView, int rawSampleIndex, ReadOnlyCollection <int> markerIdPath) { using (var rawFrameDataView = new RawFrameDataView(frameDataView.frameIndex, frameDataView.threadIndex)) { var unreachableDepth = markerIdPath == null ? frameDataView.maxDepth + 1 : markerIdPath.Count; m_CachedDeepestRawSampleIndexPath.Clear(); if (m_CachedDeepestRawSampleIndexPath.Capacity < unreachableDepth) { m_CachedDeepestRawSampleIndexPath.Capacity = unreachableDepth; } string name = null; var foundRawIndex = ProfilerTimelineGUI.FindNextSampleThroughMarkerPath(rawFrameDataView, m_ProfilerSampleNameProvider, markerIdPath, unreachableDepth, ref name, ref m_CachedDeepestRawSampleIndexPath, specificRawSampleIndexToFind: rawSampleIndex); if (foundRawIndex < 0 || foundRawIndex != rawSampleIndex) { return(HierarchyFrameDataView.invalidSampleId); } // We don't care about the path being extended here so, reduce checks by assuming the path is not expanded (this saves calls to IsExpanded) var selectedItemsPathIsExpanded = false; var newSelectedId = GetItemIdFromRawFrameDataIndexPath(frameDataView, m_CachedDeepestRawSampleIndexPath, out int deepestPath, out selectedItemsPathIsExpanded); if (deepestPath < m_CachedDeepestRawSampleIndexPath.Count) { // the path has been cut short and the sample wasn't found return(HierarchyFrameDataView.invalidSampleId); } return(newSelectedId); } }
protected override void SelectionChanged(IList <int> selectedIds) { ProfilerTimeSampleSelection selection; // When we navigate through frames and there is no path exists, // we still want to be able to frame and select proper sample once it is present again. // Thus we invalidate selection only if user selected new item. // Same applies to expanded state. if (selectedIds.Count > 0) { ClearSelection(setClearedSelection: false); } if (selectedIds.Count > 0 && m_FrameDataView.valid) { List <int> rawIds = new List <int>(); if (selectedIds.Count > 1) { List <int> ids = new List <int>(); for (int i = 0; i < selectedIds.Count; i++) { m_FrameDataView.GetItemRawFrameDataViewIndices(selectedIds[i], ids); } } else { m_FrameDataView.GetItemRawFrameDataViewIndices(selectedIds[0], rawIds); } selection = new ProfilerTimeSampleSelection(m_FrameDataView.frameIndex, m_FrameDataView.threadGroupName, m_FrameDataView.threadName, m_FrameDataView.threadId, rawIds, m_ProfilerSampleNameProvider.GetItemName(m_FrameDataView, selectedIds[0])); var selectedId = selectedIds[0]; var rawSampleIndices = new List <int>(m_FrameDataView.GetItemMergedSamplesCount(selectedId)); m_FrameDataView.GetItemRawFrameDataViewIndices(selectedId, rawSampleIndices); var markerIDs = new List <int>(m_FrameDataView.GetItemDepth(selectedId)); using (var iterator = new RawFrameDataView(m_FrameDataView.frameIndex, m_FrameDataView.threadIndex)) { string name = null; ProfilerTimelineGUI.GetItemMarkerIdPath(iterator, m_ProfilerSampleNameProvider, rawSampleIndices[0], ref name, ref markerIDs); } selection.GenerateMarkerNamePath(m_FrameDataView, markerIDs); } else { selection = null; } var id = selectedIds.Count > 0 ? selectedIds[0] : RawFrameDataView.invalidSampleIndex; if (selectionChanged != null) { selectionChanged.Invoke(selection); } }
private void BuildColumns() { ProfilerColumn[] profilerColumnArray1 = new ProfilerColumn[8]{ ProfilerColumn.FunctionName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime, ProfilerColumn.WarningCount }; ProfilerColumn[] profilerColumnArray2 = new ProfilerColumn[7]{ ProfilerColumn.ObjectName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime }; this.m_CPUHierarchyGUI = new ProfilerHierarchyGUI((IProfilerWindowController) this, "VisibleProfilerColumnsV2", profilerColumnArray1, ProfilerWindow.ProfilerColumnNames(profilerColumnArray1), false, ProfilerColumn.TotalTime); this.m_CPUTimelineGUI = new ProfilerTimelineGUI((IProfilerWindowController) this); string text = EditorGUIUtility.TextContent("Object").text; string[] columnNames1 = ProfilerWindow.ProfilerColumnNames(profilerColumnArray2); columnNames1[0] = text; this.m_CPUDetailHierarchyGUI = new ProfilerHierarchyGUI((IProfilerWindowController) this, "VisibleProfilerDetailColumns", profilerColumnArray2, columnNames1, true, ProfilerColumn.TotalTime); ProfilerColumn[] profilerColumnArray3 = new ProfilerColumn[4]{ ProfilerColumn.FunctionName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; ProfilerColumn[] profilerColumnArray4 = new ProfilerColumn[4]{ ProfilerColumn.ObjectName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; this.m_GPUHierarchyGUI = new ProfilerHierarchyGUI((IProfilerWindowController) this, "VisibleProfilerGPUColumns", profilerColumnArray3, ProfilerWindow.ProfilerColumnNames(profilerColumnArray3), false, ProfilerColumn.TotalGPUTime); string[] columnNames2 = ProfilerWindow.ProfilerColumnNames(profilerColumnArray4); columnNames2[0] = text; this.m_GPUDetailHierarchyGUI = new ProfilerHierarchyGUI((IProfilerWindowController) this, "VisibleProfilerGPUDetailColumns", profilerColumnArray4, columnNames2, true, ProfilerColumn.TotalGPUTime); }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost) { float num = (!ghost) ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; bool enterChildren = true; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag = false; float x = -1f; float num2 = -1f; float num3 = -1f; int num4 = 0; float num5 = -1f; string text = null; r.height -= 1f; GUI.BeginGroup(r); float num6 = 0f; r.y = num6; r.x = num6; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x2 = r.x; float x3 = shownArea.x; while (iter.Next(enterChildren)) { enterChildren = true; float num7 = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num8 = Mathf.Max(durationMS, 0.0003f); float num9 = ProfilerTimelineGUI.TimeToPixelCached(num7, rectWidthDivShownWidth, x3, x2); float num10 = ProfilerTimelineGUI.TimeToPixelCached(num7 + num8, rectWidthDivShownWidth, x3, x2) - 1f; float num11 = num10 - num9; if (num9 > r.x + r.width || num10 < r.x) { enterChildren = false; } else { float num12 = (float)(iter.depth - 1); float num13 = r.y + num12 * 16f; if (flag) { bool flag4 = false; if (num11 >= num) { flag4 = true; } if (num3 != num13) { flag4 = true; } if (num9 - num2 > 6f) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x, num2, num3, num4); flag = false; } } if (num11 < num) { enterChildren = false; if (!flag) { flag = true; num3 = num13; x = num9; num4 = 0; } num2 = num10; num4++; } else { int id = iter.id; string path = iter.path; bool flag5 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) { flag5 &= (id == this.m_SelectedID); } flag5 &= (threadIdx == this.m_SelectedThread); Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = ((!flag5) ? 0.75f : 1f); if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text2 = iter.name; if (flag5) { text = text2; this.m_SelectedTime = num7; this.m_SelectedDur = durationMS; num5 = num13 + 16f; } if (num11 < 20f) { text2 = string.Empty; } else { if (num11 < 50f && !flag5) { white.a *= (num11 - 20f) / 30f; } if (num11 > 200f) { text2 += string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(num9, num13, num11, 14f); GUI.Label(position, text2, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object @object = EditorUtility.InstanceIDToObject(iter.instanceId); if (@object is Component) { @object = ((Component)@object).gameObject; } if (@object != null) { if (flag2) { EditorGUIUtility.PingObject(@object.GetInstanceID()); } else { if (flag3) { Selection.objects = new List <UnityEngine.Object> { @object }.ToArray(); } } } Event.current.Use(); } flag = false; } } } if (flag) { this.DrawSmallGroup(x, num2, num3, num4); } GUI.color = color; GUI.contentColor = contentColor; if (text != null && threadIdx == this.m_SelectedThread) { string text3 = string.Format(((double)this.m_SelectedDur < 1.0) ? "{0}\n{1:f3}ms" : "{0}\n{1:f2}ms", text, this.m_SelectedDur); GUIContent content = new GUIContent(text3); GUIStyle tooltip = ProfilerTimelineGUI.styles.tooltip; Vector2 vector = tooltip.CalcSize(content); float num14 = this.m_TimeArea.TimeToPixel(this.m_SelectedTime + this.m_SelectedDur * 0.5f, r); if (num14 < r.x) { num14 = r.x + 20f; } if (num14 > r.xMax) { num14 = r.xMax - 20f; } Rect position2; if (num5 + 6f + vector.y < r.yMax) { position2 = new Rect(num14 - 32f, num5, 50f, 7f); GUI.Label(position2, GUIContent.none, ProfilerTimelineGUI.styles.tooltipArrow); } position2 = new Rect(num14, num5 + 6f, vector.x, vector.y); if (position2.xMax > r.xMax + 20f) { position2.x = r.xMax - position2.width + 20f; } if (position2.yMax > r.yMax) { position2.y = r.yMax - position2.height; } if (position2.y < r.y) { position2.y = r.y; } GUI.Label(position2, content, tooltip); } if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.m_Window.ClearSelectedPropertyPath(); this.m_SelectedID = -1; this.m_SelectedThread = threadIdx; Event.current.Use(); } GUI.EndGroup(); }
private void DrawCPUOrRenderingPane(ProfilerHierarchyGUI mainPane, ProfilerHierarchyGUI detailPane, ProfilerTimelineGUI timelinePane) { ProfilerProperty property = this.CreateProperty(false); this.DrawCPUOrRenderingToolbar(property); if (!CheckFrameData(property)) { property.Cleanup(); } else if ((timelinePane != null) && (this.m_ViewType == ProfilerViewType.Timeline)) { float height = this.m_VertSplit.realSizes[1]; height -= EditorStyles.toolbar.CalcHeight(GUIContent.none, 10f) + 2f; timelinePane.DoGUI(this.GetActiveVisibleFrameIndex(), base.position.width, base.position.height - height, height); property.Cleanup(); } else { SplitterGUILayout.BeginHorizontalSplit(this.m_ViewSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(new GUILayoutOption[0]); bool expandAll = false; mainPane.DoGUI(property, this.m_SearchString, expandAll); property.Cleanup(); GUILayout.EndVertical(); GUILayout.BeginVertical(new GUILayoutOption[0]); ProfilerProperty property2 = this.CreateProperty(true); ProfilerProperty detailedProperty = mainPane.GetDetailedProperty(property2); property2.Cleanup(); if (detailedProperty != null) { detailPane.DoGUI(detailedProperty, string.Empty, expandAll); detailedProperty.Cleanup(); } else { DrawEmptyCPUOrRenderingDetailPane(); } GUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); } }
private void BuildColumns() { ProfilerColumn[] columnArray1 = new ProfilerColumn[8]; columnArray1[1] = ProfilerColumn.TotalPercent; columnArray1[2] = ProfilerColumn.SelfPercent; columnArray1[3] = ProfilerColumn.Calls; columnArray1[4] = ProfilerColumn.GCMemory; columnArray1[5] = ProfilerColumn.TotalTime; columnArray1[6] = ProfilerColumn.SelfTime; columnArray1[7] = ProfilerColumn.WarningCount; ProfilerColumn[] columnsToShow = columnArray1; ProfilerColumn[] columns = new ProfilerColumn[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime }; this.m_CPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerColumnsV2", columnsToShow, ProfilerColumnNames(columnsToShow), false, ProfilerColumn.TotalTime); this.m_CPUTimelineGUI = new ProfilerTimelineGUI(this); string text = EditorGUIUtility.TextContent("Object").text; string[] columnNames = ProfilerColumnNames(columns); columnNames[0] = text; this.m_CPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerDetailColumns", columns, columnNames, true, ProfilerColumn.TotalTime); ProfilerColumn[] columnArray6 = new ProfilerColumn[4]; columnArray6[1] = ProfilerColumn.TotalGPUPercent; columnArray6[2] = ProfilerColumn.DrawCalls; columnArray6[3] = ProfilerColumn.TotalGPUTime; ProfilerColumn[] columnArray3 = columnArray6; ProfilerColumn[] columnArray4 = new ProfilerColumn[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; this.m_GPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUColumns", columnArray3, ProfilerColumnNames(columnArray3), false, ProfilerColumn.TotalGPUTime); columnNames = ProfilerColumnNames(columnArray4); columnNames[0] = text; this.m_GPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUDetailColumns", columnArray4, columnNames, true, ProfilerColumn.TotalGPUTime); }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int threadIdx, float timeOffset, bool ghost, bool includeSubSamples) { float num1 = !ghost ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; Color color1 = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag1 = false; float x1 = -1f; float x2 = -1f; float y1 = -1f; int size = 0; float y2 = -1f; string str = (string)null; float num2 = !includeSubSamples ? r.height : 16f; float num3 = !includeSubSamples ? 0.0f : 1f; float height = num2 - 2f * num3; r.height -= num3; GUI.BeginGroup(r); // ISSUE: explicit reference operation // ISSUE: variable of a reference type Rect& local = @r; float num4 = 0.0f; r.y = num4; double num5 = (double)num4; // ISSUE: explicit reference operation (^ local).x = (float)num5; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x3 = r.x; float x4 = shownArea.x; bool enterChildren = true; while (iter.Next(enterChildren)) { enterChildren = includeSubSamples; float time = iter.startTimeMS + timeOffset; float durationMs = iter.durationMS; float num6 = Mathf.Max(durationMs, 0.0003f); float pixelCached = ProfilerTimelineGUI.TimeToPixelCached(time, rectWidthDivShownWidth, x4, x3); float num7 = ProfilerTimelineGUI.TimeToPixelCached(time + num6, rectWidthDivShownWidth, x4, x3) - 1f; float width = num7 - pixelCached; if ((double)pixelCached > (double)r.x + (double)r.width || (double)num7 < (double)r.x) { enterChildren = false; } else { float num8 = (float)(iter.depth - 1); float y3 = r.y + num8 * num2; if (flag1) { bool flag4 = false; if ((double)width >= (double)num1) { flag4 = true; } if ((double)y1 != (double)y3) { flag4 = true; } if ((double)pixelCached - (double)x2 > 6.0) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x1, x2, y1, height, size); flag1 = false; } } if ((double)width < (double)num1) { enterChildren = false; if (!flag1) { flag1 = true; y1 = y3; x1 = pixelCached; size = 0; } x2 = num7; ++size; } else { int id = iter.id; string path = iter.path; bool flag4 = path == selectedPropertyPath && !ghost; if (this.m_SelectedID >= 0) { flag4 &= id == this.m_SelectedID; } bool flag5 = flag4 & threadIdx == this.m_SelectedThread; Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = !flag5 ? 0.75f : 1f; if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text = iter.name; if (flag5) { str = text; this.m_SelectedTime = time; this.m_SelectedDur = durationMs; y2 = y3 + num2; } if ((double)width < 20.0 || !includeSubSamples) { text = string.Empty; } else { if ((double)width < 50.0 && !flag5) { white.a *= (float)(((double)width - 20.0) / 30.0); } if ((double)width > 200.0) { text += string.Format(" ({0:f2}ms)", (object)durationMs); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(pixelCached, y3, width, height); GUI.Label(position, text, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition)) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedThread = threadIdx; this.m_SelectedID = id; UnityEngine.Object gameObject = EditorUtility.InstanceIDToObject(iter.instanceId); if (gameObject is Component) { gameObject = (UnityEngine.Object)((Component)gameObject).gameObject; } if (gameObject != (UnityEngine.Object)null) { if (flag2) { EditorGUIUtility.PingObject(gameObject.GetInstanceID()); } else if (flag3) { Selection.objects = new List <UnityEngine.Object>() { gameObject } }
private void DrawProfilingData(ProfilerFrameDataIterator iter, Rect r, int frameIndex, int threadIndex, float timeOffset, bool ghost, bool includeSubSamples) { float num = (!ghost) ? 7f : 21f; string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; Color color = GUI.color; Color contentColor = GUI.contentColor; Color[] colors = ProfilerColors.colors; bool flag = false; float x = -1f; float num2 = -1f; float num3 = -1f; int num4 = 0; float num5 = (!includeSubSamples) ? r.height : 16f; float num6 = (float)((!includeSubSamples) ? 0 : 1); float height = num5 - 2f * num6; r.height -= num6; GUI.BeginGroup(r); float num7 = 0f; r.y = num7; r.x = num7; bool flag2 = Event.current.clickCount == 1 && Event.current.type == EventType.MouseDown; bool flag3 = Event.current.clickCount == 2 && Event.current.type == EventType.MouseDown; Rect shownArea = this.m_TimeArea.shownArea; float rectWidthDivShownWidth = r.width / shownArea.width; float x2 = r.x; float x3 = shownArea.x; bool enterChildren = true; while (iter.Next(enterChildren)) { enterChildren = includeSubSamples; float num8 = iter.startTimeMS + timeOffset; float durationMS = iter.durationMS; float num9 = Mathf.Max(durationMS, 0.0003f); float num10 = ProfilerTimelineGUI.TimeToPixelCached(num8, rectWidthDivShownWidth, x3, x2); float num11 = ProfilerTimelineGUI.TimeToPixelCached(num8 + num9, rectWidthDivShownWidth, x3, x2) - 1f; float num12 = num11 - num10; if (num10 > r.x + r.width || num11 < r.x) { enterChildren = false; } else { float num13 = (float)(iter.depth - 1); float num14 = r.y + num13 * num5; if (flag) { bool flag4 = false; if (num12 >= num) { flag4 = true; } if (num3 != num14) { flag4 = true; } if (num10 - num2 > 6f) { flag4 = true; } if (flag4) { this.DrawSmallGroup(x, num2, num3, height, num4); flag = false; } } if (num12 < num) { enterChildren = false; if (!flag) { flag = true; num3 = num14; x = num10; num4 = 0; } num2 = num11; num4++; } else { int instanceId = iter.instanceId; string path = iter.path; bool flag5 = path == selectedPropertyPath && !ghost; if (this.m_SelectedEntry.instanceId >= 0) { flag5 &= (instanceId == this.m_SelectedEntry.instanceId); } flag5 &= (threadIndex == this.m_SelectedEntry.threadId); Color white = Color.white; Color color2 = colors[iter.group % colors.Length]; color2.a = ((!flag5) ? 0.75f : 1f); if (ghost) { color2.a = 0.4f; white.a = 0.5f; } string text = iter.name; if (num12 < 20f || !includeSubSamples) { text = string.Empty; } else { if (num12 < 50f && !flag5) { white.a *= (num12 - 20f) / 30f; } if (num12 > 200f) { text += string.Format(" ({0:f2}ms)", durationMS); } } GUI.color = color2; GUI.contentColor = white; Rect position = new Rect(num10, num14, num12, height); GUI.Label(position, text, ProfilerTimelineGUI.styles.bar); if ((flag2 || flag3) && position.Contains(Event.current.mousePosition) && includeSubSamples) { this.m_Window.SetSelectedPropertyPath(path); this.m_SelectedEntry.Reset(); this.m_SelectedEntry.frameId = frameIndex; this.m_SelectedEntry.threadId = threadIndex; this.m_SelectedEntry.instanceId = instanceId; this.m_SelectedEntry.name = iter.name; if (iter.extraTooltipInfo != null) { this.m_SelectedEntry.metaData = iter.extraTooltipInfo; } this.m_SelectedEntry.time = num8; this.m_SelectedEntry.duration = durationMS; this.m_SelectedEntry.relativeYPos = num14 + num5; this.UpdateSelectedObject(flag2, flag3); Event.current.Use(); } flag = false; } } } if (flag) { this.DrawSmallGroup(x, num2, num3, height, num4); } GUI.color = color; GUI.contentColor = contentColor; if (Event.current.type == EventType.MouseDown && r.Contains(Event.current.mousePosition)) { this.ClearSelection(); Event.current.Use(); } GUI.EndGroup(); }
private void BuildColumns() { ProfilerColumn[] array = new ProfilerColumn[] { ProfilerColumn.FunctionName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime, ProfilerColumn.WarningCount }; ProfilerColumn[] array2 = new ProfilerColumn[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalPercent, ProfilerColumn.SelfPercent, ProfilerColumn.Calls, ProfilerColumn.GCMemory, ProfilerColumn.TotalTime, ProfilerColumn.SelfTime }; this.m_CPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerColumnsV2", array, ProfilerWindow.ProfilerColumnNames(array), false, ProfilerColumn.TotalTime); this.m_CPUTimelineGUI = new ProfilerTimelineGUI(this); string text = EditorGUIUtility.TextContent("ProfilerColumn.DetailViewObject").text; string[] array3 = ProfilerWindow.ProfilerColumnNames(array2); array3[0] = text; this.m_CPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerDetailColumns", array2, array3, true, ProfilerColumn.TotalTime); ProfilerColumn[] array4 = new ProfilerColumn[] { ProfilerColumn.FunctionName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; ProfilerColumn[] array5 = new ProfilerColumn[] { ProfilerColumn.ObjectName, ProfilerColumn.TotalGPUPercent, ProfilerColumn.DrawCalls, ProfilerColumn.TotalGPUTime }; this.m_GPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUColumns", array4, ProfilerWindow.ProfilerColumnNames(array4), false, ProfilerColumn.TotalGPUTime); array3 = ProfilerWindow.ProfilerColumnNames(array5); array3[0] = text; this.m_GPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUDetailColumns", array5, array3, true, ProfilerColumn.TotalGPUTime); }
void MigrateSelectedState(bool expandIfNecessary, bool framingAllowed) { if (m_LocalSelectedItemMarkerIdPath == null || m_Selected == null || m_LocalSelectedItemMarkerIdPath.Count != m_Selected.markerNamePath.Count) { return; } m_SelectionNeedsMigration = false; var markerNamePath = m_Selected.markerNamePath; expandIfNecessary |= m_ExpandDuringNextSelectionMigration; using (k_MigrateSelectionStateMarker.Auto()) { var safeFrameWithSafeMarkerIds = m_Selected.frameIndexIsSafe && m_FrameDataView.frameIndex == m_Selected.safeFrameIndex; var rawHierarchyView = (m_FrameDataView.viewMode & HierarchyFrameDataView.ViewModes.MergeSamplesWithTheSameName) == HierarchyFrameDataView.ViewModes.Default; var allowProxySelection = !safeFrameWithSafeMarkerIds; var finalRawSampleIndex = RawFrameDataView.invalidSampleIndex; using (var frameData = new RawFrameDataView(m_FrameDataView.frameIndex, m_FrameDataView.threadIndex)) { if (!frameData.valid) { return; } if (!safeFrameWithSafeMarkerIds) { // marker names might have changed Ids between frames, update them if that is the case for (int i = 0; i < m_LocalSelectedItemMarkerIdPath.Count; i++) { m_LocalSelectedItemMarkerIdPath[i] = frameData.GetMarkerId(markerNamePath[i]); } } else if (!allowProxySelection) { for (int i = 0; i < m_LocalSelectedItemMarkerIdPath.Count; i++) { var markerIsEditorOnlyMarker = frameData.GetMarkerFlags(m_LocalSelectedItemMarkerIdPath[i]).HasFlag(Unity.Profiling.LowLevel.MarkerFlags.AvailabilityEditor); if (markerIsEditorOnlyMarker && i < m_LocalSelectedItemMarkerIdPath.Count - 1) { // Technically, proxy selections are not supposed to be allowed when switching between views in the same frame. // However, if there are Editor Only markers in the path that are NOT the last item, Hierarchy View might have collapsed the path from this point forward, // so we need to allow Proxy Selections here. allowProxySelection = true; break; } } } var name = m_Selected.sampleDisplayName; m_CachedDeepestRawSampleIndexPath.Clear(); if (m_CachedDeepestRawSampleIndexPath.Capacity < markerNamePath.Count) { m_CachedDeepestRawSampleIndexPath.Capacity = markerNamePath.Count; } if (allowProxySelection || rawHierarchyView) { finalRawSampleIndex = ProfilerTimelineGUI.FindFirstSampleThroughMarkerPath( frameData, m_ProfilerSampleNameProvider, m_LocalSelectedItemMarkerIdPath, markerNamePath.Count, ref name, longestMatchingPath: m_CachedDeepestRawSampleIndexPath); } else { finalRawSampleIndex = ProfilerTimelineGUI.FindNextSampleThroughMarkerPath( frameData, m_ProfilerSampleNameProvider, m_LocalSelectedItemMarkerIdPath, markerNamePath.Count, ref name, ref m_CachedDeepestRawSampleIndexPath); } } var newSelectedId = m_FrameDataView.GetRootItemID(); bool selectedItemsPathIsExpanded = true; var proxySelection = new ProxySelection(); proxySelectionInfo = default; var deepestPath = m_CachedDeepestRawSampleIndexPath.Count; if (finalRawSampleIndex >= 0 || allowProxySelection && deepestPath > 0) { // if a valid raw index was found, find the corresponding HierarchyView Sample id next: newSelectedId = GetItemIdFromRawFrameDataIndexPath(m_FrameDataView, m_CachedDeepestRawSampleIndexPath, out deepestPath, out selectedItemsPathIsExpanded); if (m_LocalSelectedItemMarkerIdPath.Count > deepestPath && newSelectedId >= 0) { proxySelection.hasProxySelection = true; proxySelection.nonProxyName = m_Selected.sampleDisplayName; proxySelection.nonProxySampleStack = m_Selected.markerNamePath; proxySelection.pathLengthDifferenceForProxy = deepestPath - m_LocalSelectedItemMarkerIdPath.Count; } } var newSelection = (newSelectedId == 0) ? new List <int>() : new List <int>() { newSelectedId }; state.selectedIDs = newSelection; // Framing invalidates expanded state and this is very expensive operation to perform each frame. // Thus we auto frame selection only when we are not currently receiving profiler data from the Editor we are profiling, or the user opted into a "Live" view of the data if (newSelectedId != 0 && isInitialized && framingAllowed && (selectedItemsPathIsExpanded || expandIfNecessary)) { FrameItem(newSelectedId); } m_ExpandDuringNextSelectionMigration = false; proxySelectionInfo = proxySelection; } }
private void BuildColumns() { ProfilerColumn[] columnsToShow = new ProfilerColumn[] { ProfilerColumn.FunctionName }; ProfilerColumn[] columns = new ProfilerColumn[] { ProfilerColumn.ObjectName }; this.m_CPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerColumnsV2", columnsToShow, ProfilerColumnNames(columnsToShow), false, ProfilerColumn.TotalTime); this.m_CPUTimelineGUI = new ProfilerTimelineGUI(this); string text = EditorGUIUtility.TextContent("Object").text; string[] columnNames = ProfilerColumnNames(columns); columnNames[0] = text; this.m_CPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerDetailColumns", columns, columnNames, true, ProfilerColumn.TotalTime); ProfilerColumn[] columnArray3 = new ProfilerColumn[] { ProfilerColumn.FunctionName }; ProfilerColumn[] columnArray4 = new ProfilerColumn[] { ProfilerColumn.ObjectName }; this.m_GPUHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUColumns", columnArray3, ProfilerColumnNames(columnArray3), false, ProfilerColumn.TotalGPUTime); columnNames = ProfilerColumnNames(columnArray4); columnNames[0] = text; this.m_GPUDetailHierarchyGUI = new ProfilerHierarchyGUI(this, "VisibleProfilerGPUDetailColumns", columnArray4, columnNames, true, ProfilerColumn.TotalGPUTime); }