public ProfilerChart(ProfilerArea area, Chart.ChartType type, float dataScale, int seriesCount) { this.m_Area = area; this.m_Type = type; this.m_DataScale = dataScale; this.m_Chart = new Chart(); this.m_Data = new ChartData(); this.m_Series = new ChartSeries[seriesCount]; this.m_Active = this.ReadActiveState(); this.ApplyActiveState(); }
public int DoChartGUI(int currentFrame, ProfilerArea currentArea, out Chart.ChartAction action) { if (Event.current.type == EventType.Repaint) { string[] strArray = new string[this.m_Series.Length]; for (int index = 0; index < this.m_Series.Length; ++index) { int statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(!this.m_Data.hasOverlay ? this.m_Series[index].identifierName : "Selected" + this.m_Series[index].identifierName); strArray[index] = ProfilerDriver.GetFormattedStatisticsValue(currentFrame, statisticsIdentifier); } this.m_Data.selectedLabels = strArray; } if (this.m_Icon == null) this.m_Icon = EditorGUIUtility.TextContentWithIcon(this.GetLocalizedChartName(), "Profiler." + Enum.GetName(typeof (ProfilerArea), (object) this.m_Area)); return this.m_Chart.DoGUI(this.m_Type, currentFrame, this.m_Data, this.m_Area, currentArea == this.m_Area, this.m_Icon, out action); }
public int DoChartGUI(int currentFrame, ProfilerArea currentArea, out Chart.ChartAction action) { if (Event.current.type == EventType.Repaint) { string[] array = new string[this.m_Series.Length]; for (int i = 0; i < this.m_Series.Length; i++) { string propertyName = (!this.m_Data.hasOverlay) ? this.m_Series[i].identifierName : ("Selected" + this.m_Series[i].identifierName); int statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(propertyName); array[i] = ProfilerDriver.GetFormattedStatisticsValue(currentFrame, statisticsIdentifier); } this.m_Data.selectedLabels = array; } if (this.m_Icon == null) { this.m_Icon = EditorGUIUtility.TextContent("Profiler." + Enum.GetName(typeof(ProfilerArea), this.m_Area)); } return this.m_Chart.DoGUI(this.m_Type, currentFrame, this.m_Data, this.m_Area, currentArea == this.m_Area, this.m_Icon, out action); }
private void OnGUI() { this.CheckForPlatformModuleChange(); if (ProfilerWindow.ms_Styles == null) { ProfilerWindow.ms_Styles = new ProfilerWindow.Styles(); } if (!this.m_HasProfilerLicense) { GUILayout.Label(ProfilerWindow.ms_Styles.noLicense, EditorStyles.largeLabel, new GUILayoutOption[0]); return; } this.DrawMainToolbar(); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[0]); this.m_GraphPos = EditorGUILayout.BeginScrollView(this.m_GraphPos, ProfilerWindow.ms_Styles.profilerGraphBackground, new GUILayoutOption[0]); if (this.m_PrevLastFrame != ProfilerDriver.lastFrameIndex) { this.UpdateCharts(); this.m_PrevLastFrame = ProfilerDriver.lastFrameIndex; } int num = this.m_CurrentFrame; Chart.ChartAction[] array = new Chart.ChartAction[this.m_Charts.Length]; for (int i = 0; i < this.m_Charts.Length; i++) { ProfilerChart profilerChart = this.m_Charts[i]; if (profilerChart.active) { num = profilerChart.DoChartGUI(num, this.m_CurrentArea, out array[i]); } } bool flag = false; if (num != this.m_CurrentFrame) { this.SetCurrentFrame(num); flag = true; } for (int j = 0; j < this.m_Charts.Length; j++) { ProfilerChart profilerChart2 = this.m_Charts[j]; if (profilerChart2.active) { if (array[j] == Chart.ChartAction.Closed) { if (this.m_CurrentArea == (ProfilerArea)j) { this.m_CurrentArea = ProfilerArea.CPU; } profilerChart2.active = false; } else { if (array[j] == Chart.ChartAction.Activated) { this.m_CurrentArea = (ProfilerArea)j; if (this.m_CurrentArea != ProfilerArea.CPU && this.m_CPUHierarchyGUI.selectedIndex != -1) { this.ClearSelectedPropertyPath(); } flag = true; } } } } if (flag) { base.Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(new GUILayoutOption[0]); switch (this.m_CurrentArea) { case ProfilerArea.CPU: this.DrawCPUOrRenderingPane(this.m_CPUHierarchyGUI, this.m_CPUDetailHierarchyGUI, this.m_CPUTimelineGUI); goto IL_255; case ProfilerArea.GPU: this.DrawCPUOrRenderingPane(this.m_GPUHierarchyGUI, this.m_GPUDetailHierarchyGUI, null); goto IL_255; case ProfilerArea.Memory: this.DrawMemoryPane(this.m_ViewSplit); goto IL_255; case ProfilerArea.Audio: this.DrawAudioPane(); goto IL_255; } this.DrawPane(this.m_CurrentArea); IL_255: GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
private void OnGUI() { this.CheckForPlatformModuleChange(); if (ms_Styles == null) { ms_Styles = new Styles(); } this.DrawMainToolbar(); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[0]); this.m_GraphPos = EditorGUILayout.BeginScrollView(this.m_GraphPos, ms_Styles.profilerGraphBackground, new GUILayoutOption[0]); if (this.m_PrevLastFrame != ProfilerDriver.lastFrameIndex) { this.UpdateCharts(); this.m_PrevLastFrame = ProfilerDriver.lastFrameIndex; } int currentFrame = this.m_CurrentFrame; Chart.ChartAction[] actionArray = new Chart.ChartAction[this.m_Charts.Length]; for (int i = 0; i < this.m_Charts.Length; i++) { ProfilerChart chart = this.m_Charts[i]; if (chart.active) { currentFrame = chart.DoChartGUI(currentFrame, this.m_CurrentArea, out actionArray[i]); } } bool flag = false; if (currentFrame != this.m_CurrentFrame) { this.SetCurrentFrame(currentFrame); flag = true; } for (int j = 0; j < this.m_Charts.Length; j++) { ProfilerChart chart2 = this.m_Charts[j]; if (chart2.active) { if (actionArray[j] == Chart.ChartAction.Closed) { if (this.m_CurrentArea == j) { this.m_CurrentArea = ProfilerArea.CPU; } chart2.active = false; } else if (actionArray[j] == Chart.ChartAction.Activated) { this.m_CurrentArea = (ProfilerArea) j; if ((this.m_CurrentArea != ProfilerArea.CPU) && (this.m_CPUHierarchyGUI.selectedIndex != -1)) { this.ClearSelectedPropertyPath(); } flag = true; } } } if (flag) { base.Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(new GUILayoutOption[0]); switch (this.m_CurrentArea) { case ProfilerArea.CPU: this.DrawCPUOrRenderingPane(this.m_CPUHierarchyGUI, this.m_CPUDetailHierarchyGUI, this.m_CPUTimelineGUI); break; case ProfilerArea.GPU: this.DrawCPUOrRenderingPane(this.m_GPUHierarchyGUI, this.m_GPUDetailHierarchyGUI, null); break; case ProfilerArea.Memory: this.DrawMemoryPane(this.m_ViewSplit); break; case ProfilerArea.Audio: this.DrawAudioPane(); break; case ProfilerArea.NetworkMessages: this.DrawPane(this.m_CurrentArea); break; case ProfilerArea.NetworkOperations: this.DrawNetworkOperationsPane(); break; default: this.DrawPane(this.m_CurrentArea); break; } GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
static public extern int GetStatisticsIdentifierForArea(ProfilerArea profilerArea, string propertyName);
private void OnGUI() { this.CheckForPlatformModuleChange(); if (ProfilerWindow.ms_Styles == null) { ProfilerWindow.ms_Styles = new ProfilerWindow.Styles(); } if (!this.m_HasProfilerLicense) { GUILayout.Label(ProfilerWindow.ms_Styles.noLicense, EditorStyles.largeLabel, new GUILayoutOption[0]); return; } this.DrawMainToolbar(); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[0]); this.m_GraphPos = EditorGUILayout.BeginScrollView(this.m_GraphPos, ProfilerWindow.ms_Styles.profilerGraphBackground, new GUILayoutOption[0]); if (this.m_PrevLastFrame != ProfilerDriver.lastFrameIndex) { this.UpdateCharts(); this.m_PrevLastFrame = ProfilerDriver.lastFrameIndex; } int num = this.m_CurrentFrame; Chart.ChartAction[] array = new Chart.ChartAction[this.m_Charts.Length]; for (int i = 0; i < this.m_Charts.Length; i++) { ProfilerChart profilerChart = this.m_Charts[i]; if (profilerChart.active) { num = profilerChart.DoChartGUI(num, this.m_CurrentArea, out array[i]); } } bool flag = false; if (num != this.m_CurrentFrame) { this.SetCurrentFrame(num); flag = true; } for (int j = 0; j < this.m_Charts.Length; j++) { ProfilerChart profilerChart2 = this.m_Charts[j]; if (profilerChart2.active) { if (array[j] == Chart.ChartAction.Closed) { if (this.m_CurrentArea == (ProfilerArea)j) { this.m_CurrentArea = ProfilerArea.CPU; } profilerChart2.active = false; } else { if (array[j] == Chart.ChartAction.Activated) { this.m_CurrentArea = (ProfilerArea)j; if (this.m_CurrentArea != ProfilerArea.CPU && this.m_CPUHierarchyGUI.selectedIndex != -1) { this.ClearSelectedPropertyPath(); } flag = true; } } } } if (flag) { base.Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(new GUILayoutOption[0]); switch (this.m_CurrentArea) { case ProfilerArea.CPU: this.DrawCPUOrRenderingPane(this.m_CPUHierarchyGUI, this.m_CPUDetailHierarchyGUI, this.m_CPUTimelineGUI); goto IL_255; case ProfilerArea.GPU: this.DrawCPUOrRenderingPane(this.m_GPUHierarchyGUI, this.m_GPUDetailHierarchyGUI, null); goto IL_255; case ProfilerArea.Memory: this.DrawMemoryPane(this.m_ViewSplit); goto IL_255; case ProfilerArea.Audio: this.DrawAudioPane(); goto IL_255; } this.DrawPane(this.m_CurrentArea); IL_255: GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
private void DrawOverviewText(ProfilerArea area) { this.m_PaneScroll[(int) area] = GUILayout.BeginScrollView(this.m_PaneScroll[(int) area], ms_Styles.background); GUILayout.Label(ProfilerDriver.GetOverviewText(area, this.GetActiveVisibleFrameIndex()), EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); GUILayout.EndScrollView(); }
static extern void GetStatisticsAvailableInternal(ProfilerArea profilerArea, int firstFrame, IntPtr buffer, int size);
static internal extern void GetStatisticsAvailabilityStates(ProfilerArea area, int firstFrame, [Out] int[] buffer);
static public extern void SetAreaEnabled(ProfilerArea area, bool enabled);
private void DrawPane(ProfilerArea area) { ProfilerWindow.DrawOtherToolbar(); this.DrawOverviewText(area); }
internal static extern void GetCounterValuesWithAvailabilityBatch(ProfilerArea area, string name, int firstFrameIndex, float scale, [Out] float[] counterValuesBuffer, [Out] int[] dataAvailableBuffer, out float maxValue);
public int DoGUI(ChartType type, int selectedFrame, ChartData cdata, ProfilerArea area, bool active, GUIContent icon, out ChartAction action) { action = ChartAction.None; if (cdata != null) { int numberOfFrames = cdata.NumberOfFrames; if (ms_Styles == null) { ms_Styles = new Styles(); } this.m_chartControlID = GUIUtility.GetControlID(s_ChartHash, FocusType.Keyboard); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinHeight(120f) }; Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ms_Styles.background, options); Rect chartFrame = rect; chartFrame.x += 170f; chartFrame.width -= 170f; Event current = Event.current; if ((current.GetTypeForControl(this.m_chartControlID) == EventType.MouseDown) && rect.Contains(current.mousePosition)) { action = ChartAction.Activated; } if (this.m_DragItemIndex == -1) { selectedFrame = this.HandleFrameSelectionEvents(selectedFrame, this.m_chartControlID, chartFrame, cdata, numberOfFrames); } Rect position = chartFrame; position.x -= 170f; position.width = 170f; GUI.Label(new Rect(position.x, position.y, position.width, 20f), GUIContent.Temp("", icon.tooltip)); if (current.type == EventType.Repaint) { ms_Styles.rightPane.Draw(chartFrame, false, false, active, false); ms_Styles.leftPane.Draw(position, EditorGUIUtility.TempContent(icon.text), false, false, active, false); if (this.m_NotSupportedWarning == null) { chartFrame.height--; if (type == ChartType.StackedFill) { this.DrawChartStacked(selectedFrame, cdata, chartFrame); } else { this.DrawChartLine(selectedFrame, cdata, chartFrame); } } else { Rect rect4 = chartFrame; rect4.x += 56.1f; rect4.y += 43f; GUI.Label(rect4, this.m_NotSupportedWarning, EditorStyles.boldLabel); } position.x += 10f; position.y += 10f; GUIStyle.none.Draw(position, EditorGUIUtility.TempContent(icon.image), false, false, false, false); position.x += 40f; this.DrawLabelDragger(type, position, cdata); } else { position.y += 10f; this.LabelDraggerDrag(this.m_chartControlID, type, cdata, position, active); } if (area == ProfilerArea.GPU) { GUI.Label(new Rect((rect.x + 170f) - ms_Styles.performanceWarning.image.width, (rect.yMax - ms_Styles.performanceWarning.image.height) - 2f, (float) ms_Styles.performanceWarning.image.width, (float) ms_Styles.performanceWarning.image.height), ms_Styles.performanceWarning); } if (GUI.Button(new Rect(((rect.x + 170f) - 13f) - 2f, rect.y + 2f, 13f, 13f), GUIContent.none, ms_Styles.closeButton)) { action = ChartAction.Closed; } } return selectedFrame; }
public ProfilerWindow() { float[] relativeSizes = new float[] { 50f, 50f }; int[] minSizes = new int[] { 50, 50 }; this.m_VertSplit = new SplitterState(relativeSizes, minSizes, null); float[] singleArray2 = new float[] { 70f, 30f }; int[] numArray2 = new int[] { 450, 50 }; this.m_ViewSplit = new SplitterState(singleArray2, numArray2, null); float[] singleArray3 = new float[] { 20f, 80f }; int[] numArray3 = new int[] { 100, 100 }; this.m_NetworkSplit = new SplitterState(singleArray3, numArray3, null); this.m_AttachProfilerUI = new AttachProfilerUI(); this.m_GraphPos = Vector2.zero; this.m_PaneScroll = new Vector2[9]; this.m_PaneScroll_AudioChannels = Vector2.zero; this.m_PaneScroll_AudioDSP = Vector2.zero; this.m_PaneScroll_AudioClips = Vector2.zero; this.m_ViewType = ProfilerViewType.Hierarchy; this.m_CurrentArea = ProfilerArea.CPU; this.m_ShowDetailedMemoryPane = ProfilerMemoryView.Simple; this.m_ShowDetailedAudioPane = ProfilerAudioView.Stats; this.m_ShowInactiveDSPChains = false; this.m_HighlightAudibleDSPChains = true; this.m_DSPGraphZoomFactor = 1f; this.m_CurrentFrame = -1; this.m_LastFrameFromTick = -1; this.m_PrevLastFrame = -1; this.m_LastAudioProfilerFrame = -1; this.m_ChartOldMax = new float[] { -1f, -1f }; this.m_ChartMaxClamp = 70000f; this.m_TimelineViewDetail = false; this.m_GatherObjectReferences = true; this.m_AudioProfilerGroupView = null; this.m_AudioProfilerClipView = null; this.m_SelectedMemRecordMode = ProfilerMemoryRecordMode.None; this.s_CheckMark = '✔'; this.msgNames = new string[] { "UserMessage", "ObjectDestroy", "ClientRpc", "ObjectSpawn", "Owner", "Command", "LocalPlayerTransform", "SyncEvent", "SyncVars", "SyncList", "ObjectSpawnScene", "NetworkInfo", "SpawnFinished", "ObjectHide", "CRC", "ClientAuthority" }; this.msgFoldouts = new bool[] { true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false }; }
public int DoGUI(ChartType type, int selectedFrame, ChartData cdata, ProfilerArea area, bool active, GUIContent icon, out ChartAction action) { action = ChartAction.None; if (cdata != null) { int numberOfFrames = cdata.NumberOfFrames; if (ms_Styles == null) { ms_Styles = new Styles(); } this.m_chartControlID = GUIUtility.GetControlID(s_ChartHash, FocusType.Keyboard); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinHeight(120f) }; Rect rect = GUILayoutUtility.GetRect(GUIContent.none, ms_Styles.background, options); Rect chartFrame = rect; chartFrame.x += 170f; chartFrame.width -= 170f; Event current = Event.current; if ((current.GetTypeForControl(this.m_chartControlID) == EventType.MouseDown) && rect.Contains(current.mousePosition)) { action = ChartAction.Activated; } if (this.m_DragItemIndex == -1) { selectedFrame = this.HandleFrameSelectionEvents(selectedFrame, this.m_chartControlID, chartFrame, cdata, numberOfFrames); } Rect position = chartFrame; position.x -= 170f; position.width = 170f; GUI.Label(new Rect(position.x, position.y, position.width, 20f), GUIContent.Temp("", icon.tooltip)); if (current.type == EventType.Repaint) { ms_Styles.rightPane.Draw(chartFrame, false, false, active, false); ms_Styles.leftPane.Draw(position, EditorGUIUtility.TempContent(icon.text), false, false, active, false); if (this.m_NotSupportedWarning == null) { chartFrame.height--; if (type == ChartType.StackedFill) { this.DrawChartStacked(selectedFrame, cdata, chartFrame); } else { this.DrawChartLine(selectedFrame, cdata, chartFrame); } } else { Rect rect4 = chartFrame; rect4.x += 56.1f; rect4.y += 43f; GUI.Label(rect4, this.m_NotSupportedWarning, EditorStyles.boldLabel); } position.x += 10f; position.y += 10f; GUIStyle.none.Draw(position, EditorGUIUtility.TempContent(icon.image), false, false, false, false); position.x += 40f; this.DrawLabelDragger(type, position, cdata); } else { position.y += 10f; this.LabelDraggerDrag(this.m_chartControlID, type, cdata, position, active); } if (area == ProfilerArea.GPU) { GUI.Label(new Rect((rect.x + 170f) - ms_Styles.performanceWarning.image.width, (rect.yMax - ms_Styles.performanceWarning.image.height) - 2f, (float)ms_Styles.performanceWarning.image.width, (float)ms_Styles.performanceWarning.image.height), ms_Styles.performanceWarning); } if (GUI.Button(new Rect(((rect.x + 170f) - 13f) - 2f, rect.y + 2f, 13f, 13f), GUIContent.none, ms_Styles.closeButton)) { action = ChartAction.Closed; } } return(selectedFrame); }
private void UpdateCharts() { int num = ProfilerDriver.maxHistoryLength - 1; int num2 = ProfilerDriver.lastFrameIndex - num; int num3 = Mathf.Max(ProfilerDriver.firstFrameIndex, num2); ProfilerChart[] charts = this.m_Charts; for (int i = 0; i < charts.Length; i++) { ProfilerChart profilerChart = charts[i]; float[] array = new float[profilerChart.m_Series.Length]; for (int j = 0; j < profilerChart.m_Series.Length; j++) { int statisticsIdentifier = ProfilerDriver.GetStatisticsIdentifier(profilerChart.m_Series[j].identifierName); float num4; ProfilerDriver.GetStatisticsValues(statisticsIdentifier, num2, profilerChart.m_DataScale, profilerChart.m_Series[j].data, out num4); num4 = Mathf.Max(num4, 0.0001f); float num5; if (profilerChart.m_Type == Chart.ChartType.Line) { num5 = 1f / (num4 * (1.05f + (float)j * 0.05f)); } else { num5 = 1f / num4; } array[j] = num5; } if (profilerChart.m_Type == Chart.ChartType.Line) { profilerChart.m_Data.AssignScale(array); } profilerChart.m_Data.Assign(profilerChart.m_Series, num2, num3); } string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; bool flag = selectedPropertyPath != string.Empty && this.m_CurrentArea == ProfilerArea.CPU; ProfilerChart profilerChart2 = this.m_Charts[0]; if (flag) { profilerChart2.m_Data.hasOverlay = true; ChartSeries[] series = profilerChart2.m_Series; for (int k = 0; k < series.Length; k++) { ChartSeries chartSeries = series[k]; int statisticsIdentifier2 = ProfilerDriver.GetStatisticsIdentifier("Selected" + chartSeries.identifierName); chartSeries.CreateOverlayData(); float num6; ProfilerDriver.GetStatisticsValues(statisticsIdentifier2, num2, profilerChart2.m_DataScale, chartSeries.overlayData, out num6); } } else { profilerChart2.m_Data.hasOverlay = false; } for (ProfilerArea profilerArea = ProfilerArea.CPU; profilerArea <= ProfilerArea.GPU; profilerArea++) { ProfilerChart profilerChart3 = this.m_Charts[(int)profilerArea]; float num7 = 0f; float num8 = 0f; for (int l = 0; l < num; l++) { float num9 = 0f; for (int m = 0; m < profilerChart3.m_Series.Length; m++) { if (profilerChart3.m_Series[m].enabled) { num9 += profilerChart3.m_Series[m].data[l]; } } if (num9 > num7) { num7 = num9; } if (num9 > num8 && l + num2 >= num3 + 1) { num8 = num9; } } if (num8 != 0f) { num7 = num8; } num7 = Math.Min(num7, this.m_ChartMaxClamp); if (this.m_ChartOldMax[(int)profilerArea] > 0f) { num7 = Mathf.Lerp(this.m_ChartOldMax[(int)profilerArea], num7, 0.4f); } this.m_ChartOldMax[(int)profilerArea] = num7; profilerChart3.m_Data.AssignScale(new float[] { 1f / num7 }); ProfilerWindow.UpdateChartGrid(num7, profilerChart3.m_Data); } string notSupportedWarning = null; if (ProfilerDriver.isGPUProfilerBuggyOnDriver) { notSupportedWarning = "Graphics card driver returned invalid timing information. Please update to a newer version if available."; } else { if (!ProfilerDriver.isGPUProfilerSupported) { notSupportedWarning = "GPU profiling is not supported by the graphics card driver. Please update to a newer version if available."; if (Application.platform == RuntimePlatform.OSXEditor) { if (!ProfilerDriver.isGPUProfilerSupportedByOS) { notSupportedWarning = "GPU profiling requires Mac OS X 10.7 (Lion) and a capable video card. GPU profiling is currently not supported on mobile."; } else { notSupportedWarning = "GPU profiling is not supported by the graphics card driver (or it was disabled because of driver bugs)."; } } } } this.m_Charts[1].m_Chart.m_NotSupportedWarning = notSupportedWarning; }
static public extern string[] GetGraphStatisticsPropertiesForArea(ProfilerArea area);
// // 摘要: // Returns whether or not a given ProfilerArea is currently enabled. // // 参数: // area: // Which area you want to check the state of. // // 返回结果: // Returns whether or not a given ProfilerArea is currently enabled. public static bool GetAreaEnabled(ProfilerArea area) { return(Profiler.GetAreaEnabled(area)); }
public static extern string GetOverviewText(ProfilerArea profilerArea, int frame);
public static void SetAreaEnabled(ProfilerArea area, bool enabled) { Profiler.SetAreaEnabled(area, enabled); }
static internal extern int GetStatisticsAvailabilityState(ProfilerArea area, int frame);
public int DoGUI(Chart.ChartType type, int selectedFrame, ChartData cdata, ProfilerArea area, bool active, GUIContent icon, out Chart.ChartAction action) { action = Chart.ChartAction.None; if (cdata == null) { return selectedFrame; } int numberOfFrames = cdata.NumberOfFrames; if (Chart.ms_Styles == null) { Chart.ms_Styles = new Chart.Styles(); } int controlID = GUIUtility.GetControlID(Chart.s_ChartHash, FocusType.Keyboard); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, Chart.ms_Styles.background, new GUILayoutOption[] { GUILayout.MinHeight(120f) }); Rect rect2 = rect; rect2.x += 170f; rect2.width -= 170f; Event current = Event.current; if (current.GetTypeForControl(controlID) == EventType.MouseDown && rect.Contains(current.mousePosition)) { action = Chart.ChartAction.Activated; } if (this.m_DragItemIndex == -1) { selectedFrame = this.HandleFrameSelectionEvents(selectedFrame, controlID, rect2, cdata, numberOfFrames); } Rect rect3 = rect2; rect3.x -= 170f; rect3.width = 170f; GUI.Label(new Rect(rect3.x, rect3.y, rect3.width, 20f), GUIContent.Temp(string.Empty, icon.tooltip)); if (current.type == EventType.Repaint) { Chart.ms_Styles.rightPane.Draw(rect2, false, false, active, false); Chart.ms_Styles.leftPane.Draw(rect3, EditorGUIUtility.TempContent(icon.text), false, false, active, false); if (this.m_NotSupportedWarning == null) { rect2.height -= 1f; if (type == Chart.ChartType.StackedFill) { this.DrawChartStacked(selectedFrame, cdata, rect2); } else { this.DrawChartLine(selectedFrame, cdata, rect2); } } else { Rect position = rect2; position.x += 56.1000023f; position.y += 43f; GUI.Label(position, this.m_NotSupportedWarning, EditorStyles.boldLabel); } rect3.x += 10f; rect3.y += 10f; GUIStyle.none.Draw(rect3, EditorGUIUtility.TempContent(icon.image), false, false, false, false); rect3.x += 40f; this.DrawLabelDragger(type, rect3, cdata); } else { rect3.y += 10f; this.LabelDraggerDrag(controlID, type, cdata, rect3, active); } if (area == ProfilerArea.GPU) { GUI.Label(new Rect(rect.x + 170f - (float)Chart.ms_Styles.performanceWarning.image.width, rect.yMax - (float)Chart.ms_Styles.performanceWarning.image.height - 2f, (float)Chart.ms_Styles.performanceWarning.image.width, (float)Chart.ms_Styles.performanceWarning.image.height), Chart.ms_Styles.performanceWarning); } if (GUI.Button(new Rect(rect.x + 170f - 13f - 2f, rect.y + 2f, 13f, 13f), GUIContent.none, Chart.ms_Styles.closeButton)) { action = Chart.ChartAction.Closed; } return selectedFrame; }
public int DoGUI(Chart.ChartType type, int selectedFrame, ChartData cdata, ProfilerArea area, bool active, GUIContent icon, out Chart.ChartAction action) { action = Chart.ChartAction.None; if (cdata == null) { return(selectedFrame); } int numberOfFrames = cdata.NumberOfFrames; if (Chart.ms_Styles == null) { Chart.ms_Styles = new Chart.Styles(); } int controlID = GUIUtility.GetControlID(Chart.s_ChartHash, FocusType.Keyboard); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, Chart.ms_Styles.background, new GUILayoutOption[] { GUILayout.MinHeight(120f) }); Rect rect2 = rect; rect2.x += 170f; rect2.width -= 170f; Event current = Event.current; if (current.GetTypeForControl(controlID) == EventType.MouseDown && rect.Contains(current.mousePosition)) { action = Chart.ChartAction.Activated; } if (this.m_DragItemIndex == -1) { selectedFrame = this.HandleFrameSelectionEvents(selectedFrame, controlID, rect2, cdata, numberOfFrames); } Rect rect3 = rect2; rect3.x -= 170f; rect3.width = 170f; GUI.Label(new Rect(rect3.x, rect3.y, rect3.width, 20f), GUIContent.Temp(string.Empty, icon.tooltip)); if (current.type == EventType.Repaint) { Chart.ms_Styles.rightPane.Draw(rect2, false, false, active, false); Chart.ms_Styles.leftPane.Draw(rect3, EditorGUIUtility.TempContent(icon.text), false, false, active, false); if (this.m_NotSupportedWarning == null) { rect2.height -= 1f; if (type == Chart.ChartType.StackedFill) { this.DrawChartStacked(selectedFrame, cdata, rect2); } else { this.DrawChartLine(selectedFrame, cdata, rect2); } } else { Rect position = rect2; position.x += 56.1000023f; position.y += 43f; GUI.Label(position, this.m_NotSupportedWarning, EditorStyles.boldLabel); } rect3.x += 10f; rect3.y += 10f; GUIStyle.none.Draw(rect3, EditorGUIUtility.TempContent(icon.image), false, false, false, false); rect3.x += 40f; this.DrawLabelDragger(type, rect3, cdata); } else { rect3.y += 10f; this.LabelDraggerDrag(controlID, type, cdata, rect3, active); } if (area == ProfilerArea.GPU) { GUI.Label(new Rect(rect.x + 170f - (float)Chart.ms_Styles.performanceWarning.image.width, rect.yMax - (float)Chart.ms_Styles.performanceWarning.image.height - 2f, (float)Chart.ms_Styles.performanceWarning.image.width, (float)Chart.ms_Styles.performanceWarning.image.height), Chart.ms_Styles.performanceWarning); } if (GUI.Button(new Rect(rect.x + 170f - 13f - 2f, rect.y + 2f, 13f, 13f), GUIContent.none, Chart.ms_Styles.closeButton)) { action = Chart.ChartAction.Closed; } return(selectedFrame); }
static public extern string GetFormattedCounterValue(int frame, ProfilerArea area, string name);
public extern static bool GetAreaEnabled(ProfilerArea area);
public static extern void GetCounterValuesBatch(ProfilerArea area, string name, int firstFrame, float scale, [Out] float[] buffer, out float maxValue);
private void DrawPane(ProfilerArea area) { DrawOtherToolbar(); this.DrawOverviewText(area); }
static void Update() { var stopFrameIndex = ProfilerDriver.lastFrameIndex; var frameIndex = Math.Max(frameCursor + 1, ProfilerDriver.firstFrameIndex); while (frameIndex <= stopFrameIndex) { var samples = new Dictionary <int, StackSample>(); var relations = new Dictionary <int, int>(); var cursor = new Stack <int>(); var sequence = 0; var root = new ProfilerProperty(); root.SetRoot(frameIndex, ProfilerColumn.TotalTime, ProfilerViewType.Hierarchy); root.onlyShowGPUSamples = false; while (root.Next(true)) { var depth = root.depth; while (cursor.Count + 1 > depth) { cursor.Pop(); } var drawCalls = root.GetColumnAsSingle(ProfilerColumn.DrawCalls); samples.Add(sequence, new StackSample { id = sequence, name = root.propertyName, callsCount = (int)root.GetColumnAsSingle(ProfilerColumn.Calls), gcAllocBytes = (int)root.GetColumnAsSingle(ProfilerColumn.GCMemory), totalTime = root.GetColumnAsSingle(ProfilerColumn.TotalTime), selfTime = root.GetColumnAsSingle(ProfilerColumn.SelfTime), }); if (cursor.Count != 0) { relations[sequence] = cursor.Peek(); } if (root.HasChildren) { cursor.Push(sequence); } ++sequence; } // encode frame index var frameFPS = float.Parse(root.frameFPS); stream.Write(frameIndex); stream.Write(string.IsNullOrEmpty(root.frameTime) ? (1000f / frameFPS) : float.Parse(root.frameTime)); stream.Write(frameFPS); //encode statistics for (ProfilerArea area = 0; area < ProfilerArea.AreaCount; area++) { var statistics = metadatas[(int)area]; stream.Write((byte)area); for (var i = 0; i < statistics.Count; i++) { var maxValue = 0.0f; var identifier = statistics[i]; ProfilerDriver.GetStatisticsValues(identifier, frameIndex, 1.0f, provider, out maxValue); stream.Write(provider[0]); } } // encode samples stream.Write(samples.Count); foreach (var pair in samples) { var v = pair.Value; stream.Write(v.id); stream.Write(getStringRef(v.name)); stream.Write(v.callsCount); stream.Write(v.gcAllocBytes); stream.Write(v.totalTime); stream.Write(v.selfTime); } // encode relations stream.Write(relations.Count); foreach (var pair in relations) { stream.Write(pair.Key); stream.Write(pair.Value); } stream.Write((uint)0x12345678); // magic number // next frame ++frameIndex; } frameCursor = stopFrameIndex; }
void Start() { var profilingAreas = new ProfilerArea[] { ProfilerArea.CPU, ProfilerArea.GPU, ProfilerArea.Physics }; ProfilerManager.EnableProfiling(profilingAreas); }
private void OnGUI() { this.CheckForPlatformModuleChange(); if (ProfilerWindow.ms_Styles == null) ProfilerWindow.ms_Styles = new ProfilerWindow.Styles(); this.DrawMainToolbar(); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit); this.m_GraphPos = EditorGUILayout.BeginScrollView(this.m_GraphPos, ProfilerWindow.ms_Styles.profilerGraphBackground, new GUILayoutOption[0]); if (this.m_PrevLastFrame != ProfilerDriver.lastFrameIndex) { this.UpdateCharts(); this.m_PrevLastFrame = ProfilerDriver.lastFrameIndex; } int num = this.m_CurrentFrame; Chart.ChartAction[] chartActionArray = new Chart.ChartAction[this.m_Charts.Length]; for (int index = 0; index < this.m_Charts.Length; ++index) { ProfilerChart chart = this.m_Charts[index]; if (chart.active) num = chart.DoChartGUI(num, this.m_CurrentArea, out chartActionArray[index]); } bool flag = false; if (num != this.m_CurrentFrame) { this.SetCurrentFrame(num); flag = true; } for (int index = 0; index < this.m_Charts.Length; ++index) { ProfilerChart chart = this.m_Charts[index]; if (chart.active) { if (chartActionArray[index] == Chart.ChartAction.Closed) { if (this.m_CurrentArea == (ProfilerArea) index) this.m_CurrentArea = ProfilerArea.CPU; chart.active = false; } else if (chartActionArray[index] == Chart.ChartAction.Activated) { this.m_CurrentArea = (ProfilerArea) index; if (this.m_CurrentArea != ProfilerArea.CPU && this.m_CPUHierarchyGUI.selectedIndex != -1) this.ClearSelectedPropertyPath(); flag = true; } } } if (flag) { this.Repaint(); GUIUtility.ExitGUI(); } GUILayout.EndScrollView(); GUILayout.BeginVertical(); switch (this.m_CurrentArea) { case ProfilerArea.CPU: this.DrawCPUOrRenderingPane(this.m_CPUHierarchyGUI, this.m_CPUDetailHierarchyGUI, this.m_CPUTimelineGUI); break; case ProfilerArea.GPU: this.DrawCPUOrRenderingPane(this.m_GPUHierarchyGUI, this.m_GPUDetailHierarchyGUI, (ProfilerTimelineGUI) null); break; case ProfilerArea.Memory: this.DrawMemoryPane(this.m_ViewSplit); break; case ProfilerArea.Audio: this.DrawAudioPane(); break; case ProfilerArea.NetworkMessages: this.DrawPane(this.m_CurrentArea); break; case ProfilerArea.NetworkOperations: this.DrawNetworkOperationsPane(); break; default: this.DrawPane(this.m_CurrentArea); break; } GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); }
static public extern string GetOverviewText(ProfilerArea profilerArea, int frame);
protected static void DrawOtherToolbar(ProfilerArea area) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); }
internal void DrawUIPane(ProfilerWindow win, ProfilerArea profilerArea, UISystemProfilerChart detailsChart) { this.InitIfNeeded(win); EditorGUILayout.BeginVertical(new GUILayoutOption[0]); if (this.m_DetachedPreview != null && !this.m_DetachedPreview) { this.m_DetachedPreview = null; } bool flag = this.m_DetachedPreview; if (!flag) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); SplitterGUILayout.BeginHorizontalSplit(this.m_TreePreviewHorizontalSplitState, new GUILayoutOption[0]); } Rect controlRect = EditorGUILayout.GetControlRect(new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); controlRect.yMin -= EditorGUIUtility.standardVerticalSpacing; this.m_TreeViewControl.property = win.CreateProperty(); if (!this.m_TreeViewControl.property.frameDataReady) { this.m_TreeViewControl.property.Cleanup(); this.m_TreeViewControl.property = null; GUI.Label(controlRect, UISystemProfiler.Styles.noData); } else { int activeVisibleFrameIndex = win.GetActiveVisibleFrameIndex(); if (this.m_UGUIProfilerTreeViewState != null && this.m_UGUIProfilerTreeViewState.lastFrame != activeVisibleFrameIndex) { this.currentFrame = ProfilerDriver.lastFrameIndex - activeVisibleFrameIndex; this.m_TreeViewControl.Reload(); } this.m_TreeViewControl.OnGUI(controlRect); this.m_TreeViewControl.property.Cleanup(); } if (!flag) { using (new EditorGUILayout.VerticalScope(new GUILayoutOption[0])) { using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar, new GUILayoutOption[] { GUILayout.ExpandWidth(true) })) { flag = GUILayout.Button(UISystemProfiler.Styles.contentDetachRender, EditorStyles.toolbarButton, new GUILayoutOption[] { GUILayout.Width(75f) }); if (flag) { this.m_DetachedPreview = EditorWindow.GetWindow <UISystemPreviewWindow>(); this.m_DetachedPreview.profiler = this; this.m_DetachedPreview.Show(); } UISystemProfiler.DrawPreviewToolbarButtons(); } this.DrawRenderUI(); } GUILayout.EndHorizontal(); SplitterGUILayout.EndHorizontalSplit(); EditorGUI.DrawRect(new Rect((float)this.m_TreePreviewHorizontalSplitState.realSizes[0] + controlRect.xMin, controlRect.y, 1f, controlRect.height), UISystemProfiler.Styles.separatorColor); } EditorGUILayout.EndVertical(); if (this.m_DetachedPreview) { this.m_DetachedPreview.Repaint(); } }
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(); } }
static public extern bool IsAreaEnabled(ProfilerArea area);
public static extern string[] GetGraphStatisticsPropertiesForArea(ProfilerArea area);
static public extern void GetStatisticsAvailable(ProfilerArea profilerArea, int firstFrame, [Out] bool[] buffer);
private void DrawOverviewText(ProfilerArea area) { this.m_PaneScroll[(int)area] = GUILayout.BeginScrollView(this.m_PaneScroll[(int)area], ProfilerWindow.ms_Styles.background); GUILayout.Label(ProfilerDriver.GetOverviewText(area, this.GetActiveVisibleFrameIndex()), EditorStyles.wordWrappedLabel, new GUILayoutOption[0]); GUILayout.EndScrollView(); }