private void DrawCPUOrRenderingToolbar(ProfilerProperty property) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); string[] displayedOptions = new string[] { "Hierarchy", "Timeline", "Raw Hierarchy" }; int[] optionValues = new int[] { 0, 1, 2 }; this.m_ViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)this.m_ViewType, displayedOptions, optionValues, EditorStyles.toolbarDropDown, new GUILayoutOption[] { GUILayout.Width(100f) }); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("CPU:{0}ms GPU:{1}ms", property.frameTime, property.frameGpuTime), EditorStyles.miniLabel, new GUILayoutOption[0]); GUI.enabled = (ProfilerDriver.GetNextFrameIndex(this.m_CurrentFrame) == -1); if (GUILayout.Button((!GUI.enabled) ? ProfilerWindow.ms_Styles.noFrameDebugger : ProfilerWindow.ms_Styles.frameDebugger, EditorStyles.toolbarButton, new GUILayoutOption[0])) { FrameDebuggerWindow frameDebuggerWindow = FrameDebuggerWindow.ShowFrameDebuggerWindow(); frameDebuggerWindow.EnableIfNeeded(); } GUI.enabled = true; GUILayout.FlexibleSpace(); this.SearchFieldGUI(); EditorGUILayout.EndHorizontal(); this.HandleCommandEvents(); }
private ProfilerProperty GetDetailedProperty(int frameIndex, ProfilerViewType viewType) { ProfilerProperty result; if (this.m_CachedProfilerPropertyConfig.frameIndex == frameIndex && this.m_CachedProfilerPropertyConfig.sortType == this.m_ProfilerHierarchyGUI.sortType && this.m_CachedProfilerPropertyConfig.viewType == viewType && this.m_CachedProfilerPropertyConfig.propertyPath == ProfilerDriver.selectedPropertyPath) { result = this.m_CachedProfilerProperty; } else { string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; ProfilerProperty detailedProperty = this.m_MainProfilerHierarchyGUI.GetDetailedProperty(); if (this.m_CachedProfilerProperty != null) { this.m_CachedProfilerProperty.Cleanup(); } this.m_CachedProfilerPropertyConfig.frameIndex = frameIndex; this.m_CachedProfilerPropertyConfig.sortType = this.m_ProfilerHierarchyGUI.sortType; this.m_CachedProfilerPropertyConfig.viewType = viewType; this.m_CachedProfilerPropertyConfig.propertyPath = selectedPropertyPath; this.m_CachedProfilerProperty = detailedProperty; result = detailedProperty; } return(result); }
public void Set(int frameIndex, ProfilerViewType viewType, ProfilerColumn sortType) { this.frameIndex = frameIndex; this.sortType = sortType; this.viewType = viewType; this.propertyPath = ProfilerDriver.selectedPropertyPath; }
public void DoGUI(GUIStyle headerStyle, int frameIndex, ProfilerViewType viewType) { string selectedPropertyPath = ProfilerDriver.selectedPropertyPath; if (string.IsNullOrEmpty(selectedPropertyPath)) { base.DrawEmptyPane(headerStyle); } else { this.InitIfNeeded(); this.UpdateIfNeeded(frameIndex, viewType, selectedPropertyPath); GUILayout.BeginVertical(new GUILayoutOption[0]); GUILayout.Label(this.m_TotalSelectedPropertyTimeLabel, EditorStyles.label, new GUILayoutOption[0]); SplitterGUILayout.BeginVerticalSplit(this.m_VertSplit, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true) }); Rect r = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); this.m_CalleesTreeView.OnGUI(r); EditorGUILayout.EndVertical(); r = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); this.m_CallersTreeView.OnGUI(r); EditorGUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); GUILayout.EndVertical(); } }
protected void DrawViewTypePopup(ProfilerViewType viewType) { ProfilerViewType newViewType; if (!gpuView) { newViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, kCPUProfilerViewTypeNames, kCPUProfilerViewTypes, BaseStyles.viewTypeToolbarDropDown); } else { if (viewType == ProfilerViewType.Timeline) { viewType = ProfilerViewType.Hierarchy; } newViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, kGPUProfilerViewTypeNames, kGPUProfilerViewTypes, BaseStyles.viewTypeToolbarDropDown); } if (newViewType != viewType) { if (viewTypeChanged != null) { viewTypeChanged.Invoke(newViewType); } } }
protected void CPUOrGPUViewTypeChanged(ProfilerViewType viewtype) { if (m_ViewType == viewtype) { return; } m_ViewType = viewtype; }
public override void OnEnable(IProfilerWindowController profilerWindow) { base.OnEnable(profilerWindow); if (m_FrameDataHierarchyView == null) { m_FrameDataHierarchyView = new ProfilerFrameDataHierarchyView(HierarchyViewSettingsKeyPrefix); } m_FrameDataHierarchyView.gpuView = false; m_FrameDataHierarchyView.viewTypeChanged += CPUOrGPUViewTypeChanged; m_FrameDataHierarchyView.selectionChanged += CPUOrGPUViewSelectionChanged; m_ProfilerWindow.selectionChanged += m_FrameDataHierarchyView.SetSelectionFromLegacyPropertyPath; m_ViewType = (ProfilerViewType)EditorPrefs.GetInt(ViewTypeSettingsKey, (int)DefaultViewTypeSetting); }
public void DoGUI(GUIStyle headerStyle, int frameIndex, ProfilerViewType viewType) { ProfilerProperty detailedProperty = this.GetDetailedProperty(frameIndex, viewType); if (detailedProperty != null) { this.m_ProfilerHierarchyGUI.DoGUI(detailedProperty, string.Empty, false); } else { this.DrawEmptyPane(headerStyle); } }
public override void OnEnable(IProfilerWindowController profilerWindow) { base.OnEnable(profilerWindow); if (m_FrameDataHierarchyView == null) { m_FrameDataHierarchyView = new ProfilerFrameDataHierarchyView(); } m_FrameDataHierarchyView.gpuView = false; m_FrameDataHierarchyView.viewTypeChanged += CPUOrGPUViewTypeChanged; m_FrameDataHierarchyView.selectionChanged += CPUOrGPUViewSelectionChanged; m_ProfilerWindow.selectionChanged += m_FrameDataHierarchyView.SetSelectionFromLegacyPropertyPath; // Automatic Serialization on Domain Reload does not work yet as the base is abstract and the array on the ProfilerWindwo is of type ProfilerModuleBase m_ViewType = (ProfilerViewType)EditorPrefs.GetInt(ViewTypeSettingsKey, (int)DefaultViewTypeSetting); }
static GUIContent GetCPUProfilerViewTypeName(ProfilerViewType viewType) { switch (viewType) { case ProfilerViewType.Hierarchy: return(kCPUProfilerViewTypeNames[1]); case ProfilerViewType.Timeline: return(kCPUProfilerViewTypeNames[0]); case ProfilerViewType.RawHierarchy: return(kCPUProfilerViewTypeNames[2]); default: throw new NotImplementedException($"Lookup Not Implemented for {viewType}"); } }
private ProfilerProperty GetDetailedProperty(int frameIndex, ProfilerViewType viewType, ProfilerColumn sortType) { ProfilerProperty result; if (this.m_CachedProfilerPropertyConfig.EqualsTo(frameIndex, viewType, sortType)) { result = this.m_CachedProfilerProperty; } else { ProfilerProperty detailedProperty = this.m_MainProfilerHierarchyGUI.GetDetailedProperty(); if (this.m_CachedProfilerProperty != null) { this.m_CachedProfilerProperty.Cleanup(); } this.m_CachedProfilerPropertyConfig.Set(frameIndex, viewType, sortType); this.m_CachedProfilerProperty = detailedProperty; result = detailedProperty; } return(result); }
protected void DrawViewTypePopup(ProfilerViewType viewType) { ProfilerViewType newViewType; if (!gpuView) { newViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, kCPUProfilerViewTypeNames, kCPUProfilerViewTypes, BaseStyles.viewTypeToolbarDropDown, GUILayout.Width(BaseStyles.viewTypeToolbarDropDown.fixedWidth)); } else { if (viewType == ProfilerViewType.Timeline) { viewType = ProfilerViewType.Hierarchy; } newViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, kGPUProfilerViewTypeNames, kGPUProfilerViewTypes, BaseStyles.viewTypeToolbarDropDown, GUILayout.Width(BaseStyles.viewTypeToolbarDropDown.fixedWidth)); } if (newViewType != viewType) { viewTypeChanged(newViewType); GUIUtility.ExitGUI(); } }
protected void DrawViewTypePopup(ProfilerViewType viewType) { ProfilerViewType profilerViewType; if (!this.gpuView) { profilerViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, ProfilerFrameDataViewBase.kCPUProfilerViewTypeNames, ProfilerFrameDataViewBase.kCPUProfilerViewTypes, ProfilerFrameDataViewBase.BaseStyles.viewTypeToolbarDropDown, new GUILayoutOption[0]); } else { if (viewType == ProfilerViewType.Timeline) { viewType = ProfilerViewType.Hierarchy; } profilerViewType = (ProfilerViewType)EditorGUILayout.IntPopup((int)viewType, ProfilerFrameDataViewBase.kGPUProfilerViewTypeNames, ProfilerFrameDataViewBase.kGPUProfilerViewTypes, ProfilerFrameDataViewBase.BaseStyles.viewTypeToolbarDropDown, new GUILayoutOption[0]); } if (profilerViewType != viewType) { if (this.viewTypeChanged != null) { this.viewTypeChanged(profilerViewType); } } }
private void UpdateIfNeeded(int frameIndex, ProfilerViewType viewType, string selectedPropertyPath) { if (!this.m_CachedProfilerPropertyConfig.EqualsTo(frameIndex, viewType, ProfilerColumn.DontSort)) { ProfilerProperty rootProperty = this.m_MainProfilerHierarchyGUI.GetRootProperty(); string profilerPropertyName = ProfilerDetailedCallsView.GetProfilerPropertyName(selectedPropertyPath); this.m_TotalSelectedPropertyTime = 0f; Dictionary <string, ProfilerDetailedCallsView.CallInformation> dictionary = new Dictionary <string, ProfilerDetailedCallsView.CallInformation>(); Dictionary <string, ProfilerDetailedCallsView.CallInformation> dictionary2 = new Dictionary <string, ProfilerDetailedCallsView.CallInformation>(); Stack <ProfilerDetailedCallsView.ParentCallInfo> stack = new Stack <ProfilerDetailedCallsView.ParentCallInfo>(); bool flag = false; while (rootProperty.Next(true)) { string propertyName = rootProperty.propertyName; int depth = rootProperty.depth; if (stack.Count + 1 != depth) { while (stack.Count + 1 > depth) { stack.Pop(); } flag = (stack.Count != 0 && profilerPropertyName == stack.Peek().name); } if (stack.Count != 0) { ProfilerDetailedCallsView.ParentCallInfo parentCallInfo = stack.Peek(); if (profilerPropertyName == propertyName) { float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime); int num = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.Calls); int num2 = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.GCMemory); ProfilerDetailedCallsView.CallInformation callInformation; if (!dictionary.TryGetValue(parentCallInfo.name, out callInformation)) { dictionary.Add(parentCallInfo.name, new ProfilerDetailedCallsView.CallInformation { name = parentCallInfo.name, path = parentCallInfo.path, callsCount = num, gcAllocBytes = num2, totalCallTimeMs = (double)parentCallInfo.timeMs, totalSelfTimeMs = (double)columnAsSingle }); } else { callInformation.callsCount += num; callInformation.gcAllocBytes += num2; callInformation.totalCallTimeMs += (double)parentCallInfo.timeMs; callInformation.totalSelfTimeMs += (double)columnAsSingle; } this.m_TotalSelectedPropertyTime += columnAsSingle; } if (flag) { float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime); int num = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.Calls); int num2 = (int)rootProperty.GetColumnAsSingle(ProfilerColumn.GCMemory); ProfilerDetailedCallsView.CallInformation callInformation; if (!dictionary2.TryGetValue(propertyName, out callInformation)) { dictionary2.Add(propertyName, new ProfilerDetailedCallsView.CallInformation { name = propertyName, path = rootProperty.propertyPath, callsCount = num, gcAllocBytes = num2, totalCallTimeMs = (double)columnAsSingle, totalSelfTimeMs = 0.0 }); } else { callInformation.callsCount += num; callInformation.gcAllocBytes += num2; callInformation.totalCallTimeMs += (double)columnAsSingle; } } } else if (profilerPropertyName == propertyName) { float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime); this.m_TotalSelectedPropertyTime += columnAsSingle; } if (rootProperty.HasChildren) { float columnAsSingle = rootProperty.GetColumnAsSingle(ProfilerColumn.TotalTime); stack.Push(new ProfilerDetailedCallsView.ParentCallInfo { name = propertyName, path = rootProperty.propertyPath, timeMs = columnAsSingle }); flag = (profilerPropertyName == propertyName); } } this.m_CallersTreeView.SetCallsData(new ProfilerDetailedCallsView.CallsData { calls = dictionary.Values.ToList <ProfilerDetailedCallsView.CallInformation>(), totalSelectedPropertyTime = this.m_TotalSelectedPropertyTime }); this.m_CalleesTreeView.SetCallsData(new ProfilerDetailedCallsView.CallsData { calls = dictionary2.Values.ToList <ProfilerDetailedCallsView.CallInformation>(), totalSelectedPropertyTime = this.m_TotalSelectedPropertyTime }); this.m_TotalSelectedPropertyTimeLabel.text = profilerPropertyName + string.Format(" - Total time: {0:f2} ms", this.m_TotalSelectedPropertyTime); this.m_CachedProfilerPropertyConfig.Set(frameIndex, viewType, ProfilerColumn.TotalTime); } }
public FrameDataView(ProfilerViewType viewType, int frameIndex, int threadIndex, ProfilerColumn profilerSortColumn, bool sortAscending, FrameViewFilteringModes collapseEditorSamples) { m_Ptr = Internal_Create(viewType, frameIndex, threadIndex, profilerSortColumn, sortAscending, collapseEditorSamples); }
private void DrawCPUOrRenderingToolbar(ProfilerProperty property) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); string[] displayedOptions = new string[] { "Hierarchy", "Timeline", "Raw Hierarchy" }; int[] numArray1 = new int[3]; numArray1[1] = 1; numArray1[2] = 2; int[] optionValues = numArray1; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(100f) }; this.m_ViewType = (ProfilerViewType) EditorGUILayout.IntPopup((int) this.m_ViewType, displayedOptions, optionValues, EditorStyles.toolbarDropDown, options); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("CPU:{0}ms GPU:{1}ms", property.frameTime, property.frameGpuTime), EditorStyles.miniLabel, new GUILayoutOption[0]); GUI.enabled = ProfilerDriver.GetNextFrameIndex(this.m_CurrentFrame) == -1; if (GUILayout.Button(!GUI.enabled ? ms_Styles.noFrameDebugger : ms_Styles.frameDebugger, EditorStyles.toolbarButton, new GUILayoutOption[0])) { FrameDebuggerWindow.ShowFrameDebuggerWindow().EnableIfNeeded(); } GUI.enabled = true; if (ProfilerInstrumentationPopup.InstrumentationEnabled && GUILayout.Button(ms_Styles.profilerInstrumentation, EditorStyles.toolbarDropDown, new GUILayoutOption[0])) { ProfilerInstrumentationPopup.Show(GUILayoutUtility.topLevel.GetLast()); } GUILayout.FlexibleSpace(); this.SearchFieldGUI(); EditorGUILayout.EndHorizontal(); this.HandleCommandEvents(); }
private void DrawCPUOrRenderingToolbar(ProfilerProperty property) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); string[] displayedOptions = new string[] { "Hierarchy", "Timeline", "Raw Hierarchy" }; int[] numArray1 = new int[3]; numArray1[1] = 1; numArray1[2] = 2; int[] optionValues = numArray1; GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(120f) }; this.m_ViewType = (ProfilerViewType) EditorGUILayout.IntPopup((int) this.m_ViewType, displayedOptions, optionValues, EditorStyles.toolbarDropDown, options); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("CPU:{0}ms GPU:{1}ms", property.frameTime, property.frameGpuTime), EditorStyles.miniLabel, new GUILayoutOption[0]); GUI.enabled = ProfilerDriver.GetNextFrameIndex(this.m_CurrentFrame) == -1; if (GUILayout.Button(!GUI.enabled ? ms_Styles.noFrameDebugger : ms_Styles.frameDebugger, EditorStyles.toolbarButton, new GUILayoutOption[0])) { FrameDebuggerWindow.ShowFrameDebuggerWindow().EnableIfNeeded(); } GUI.enabled = true; if (ProfilerInstrumentationPopup.InstrumentationEnabled && GUILayout.Button(ms_Styles.profilerInstrumentation, EditorStyles.toolbarDropDown, new GUILayoutOption[0])) { ProfilerInstrumentationPopup.Show(GUILayoutUtility.topLevel.GetLast()); } GUILayout.FlexibleSpace(); if (this.m_ViewType == ProfilerViewType.Timeline) { this.m_TimelineViewDetail = GUILayout.Toggle(this.m_TimelineViewDetail, ms_Styles.timelineHighDetail, EditorStyles.toolbarButton, new GUILayoutOption[0]); ms_Styles.memRecord.text = "Mem Record"; if (this.m_SelectedMemRecordMode != ProfilerMemoryRecordMode.None) { string text = ms_Styles.memRecord.text; object[] objArray1 = new object[] { text, " [", this.s_CheckMark, "]" }; ms_Styles.memRecord.text = string.Concat(objArray1); } GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.Width(100f) }; Rect position = GUILayoutUtility.GetRect(ms_Styles.memRecord, EditorStyles.toolbarDropDown, optionArray2); if (EditorGUI.ButtonMouseDown(position, ms_Styles.memRecord, FocusType.Passive, EditorStyles.toolbarDropDown)) { string[] strArray2 = new string[] { "None", "Sample only", "Callstack (fast)", "Callstack (full)" }; bool[] enabled = new bool[strArray2.Length]; for (int i = 0; i < strArray2.Length; i++) { enabled[i] = true; } int[] selected = new int[] { this.m_SelectedMemRecordMode }; EditorUtility.DisplayCustomMenu(position, strArray2, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.MemRecordModeClick), null); } } else { this.SearchFieldGUI(); } EditorGUILayout.EndHorizontal(); this.HandleCommandEvents(); }
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 extern void SetRoot(int frame, ProfilerColumn profilerSortColumn, ProfilerViewType viewType);
public bool EqualsTo(int frameIndex, ProfilerViewType viewType, ProfilerColumn sortType) { return(this.frameIndex == frameIndex && this.sortType == sortType && this.viewType == viewType && this.propertyPath == ProfilerDriver.selectedPropertyPath); }
public FrameDataView(ProfilerViewType viewType, int frameIndex, int threadIndex, ProfilerColumn profilerSortColumn, bool sortAscending) { m_Ptr = Internal_Create(viewType, frameIndex, threadIndex, profilerSortColumn, sortAscending); }
void DrawToolbar(HierarchyFrameDataView frameDataView, bool showDetailedView, ref bool updateViewLive, ProfilerViewType viewType) { EditorGUILayout.BeginHorizontal(BaseStyles.toolbar); DrawViewTypePopup(viewType); DrawLiveUpdateToggle(ref updateViewLive); if (!gpuView) { DrawThreadPopup(frameDataView); } GUILayout.FlexibleSpace(); if (frameDataView != null && frameDataView.valid) { DrawCPUGPUTime(frameDataView.frameTimeMs, frameDataView.frameGpuTimeMs); } GUILayout.FlexibleSpace(); DrawSearchBar(); if (!showDetailedView) { DrawDetailedViewPopup(); EditorGUILayout.Space(); // workaround: Remove double lines cpuModule?.DrawOptionsMenuPopup(); } EditorGUILayout.EndHorizontal(); }
public void DoGUI(HierarchyFrameDataView frameDataView, bool fetchData, ref bool updateViewLive, ProfilerViewType viewType) { using (m_DoGUIMarker.Auto()) { if (Event.current.type != EventType.Layout && m_ThreadIndexDuringLastNonLayoutEvent != threadIndexInThreadNames) { m_ThreadIndexDuringLastNonLayoutEvent = threadIndexInThreadNames; EditorGUIUtility.ExitGUI(); } InitIfNeeded(); var isSearchAllowed = string.IsNullOrEmpty(treeView.searchString) || !(m_ProfilerWindow.ProfilerWindowOverheadIsAffectingProfilingRecordingData() && ProfilerDriver.deepProfiling); var isDataAvailable = frameDataView != null && frameDataView.valid; var showDetailedView = isDataAvailable && m_DetailedViewType != DetailedViewType.None; if (showDetailedView) { SplitterGUILayout.BeginHorizontalSplit(m_DetailedViewSpliterState); } // Hierarchy view area GUILayout.BeginVertical(); if (isDataAvailable && (threadIndex != frameDataView.threadIndex || threadName != frameDataView.threadName)) { SetFrameDataView(frameDataView); } DrawToolbar(frameDataView, showDetailedView, ref updateViewLive, viewType); if (!string.IsNullOrEmpty(dataAvailabilityMessage)) { GUILayout.Label(dataAvailabilityMessage, BaseStyles.label); } else if (!isDataAvailable) { if (!fetchData && !updateViewLive) { GUILayout.Label(BaseStyles.liveUpdateMessage, BaseStyles.label); } else { GUILayout.Label(BaseStyles.noData, BaseStyles.label); } } else if (!isSearchAllowed) { GUILayout.Label(BaseStyles.disabledSearchText, BaseStyles.label); } else { var rect = GUILayoutUtility.GetRect(GUIContent.none, GUIStyle.none, GUILayout.ExpandHeight(true), GUILayout.ExpandHeight(true)); m_TreeView.SetFrameDataView(frameDataView); m_TreeView.OnGUI(rect, updateViewLive); if (m_TreeView.HasSelection() && m_TreeView.proxySelectionInfo.hasProxySelection) { if (m_TreeView.proxySelectionInfo.cachedDisplayContent == null) { var diff = Math.Abs(m_TreeView.proxySelectionInfo.pathLengthDifferenceForProxy); m_TreeView.proxySelectionInfo.cachedDisplayContent = new GUIContent( BaseStyles.selectionExtraInfoHierarhcyView + string.Format( BaseStyles.proxySampleMessage, m_TreeView.proxySelectionInfo.nonProxyName, diff, diff == 1 ? BaseStyles.proxySampleMessageScopeSingular : BaseStyles.proxySampleMessageScopePlural), BaseStyles.warningTriangle.image); } GUILayout.BeginHorizontal(); GUILayout.Box(m_TreeView.proxySelectionInfo.cachedDisplayContent, BaseStyles.selectionExtraInfoArea); var rectForSampleStackButton = GUILayoutUtility.GetRect(BaseStyles.showDetailsDropdownContent, BaseStyles.tooltipDropdown, GUILayout.ExpandHeight(false), GUILayout.ExpandHeight(false)); if (GUI.Button(rectForSampleStackButton, BaseStyles.showDetailsDropdownContent, BaseStyles.tooltipDropdown)) { var selection = m_TreeView.GetSelection(); var selectedId = (selection != null && selection.Count > 0) ? selection[0] : ProfilerFrameDataHierarchyView.invalidTreeViewId; if (selectedId >= 0) { var menu = new GenericMenu(); // Show Sample Selection: var rawSampleIndices = new List <int>(frameDataView.GetItemMergedSamplesCount(selectedId)); frameDataView.GetItemRawFrameDataViewIndices(selectedId, rawSampleIndices); var actualMarkerIdPath = new List <int>(frameDataView.GetItemDepth(selectedId)); using (var iterator = new RawFrameDataView(frameDataView.frameIndex, frameDataView.threadIndex)) { string name = null; var rawIndex = ProfilerTimelineGUI.GetItemMarkerIdPath(iterator, cpuModule, rawSampleIndices[0], ref name, ref actualMarkerIdPath); } var actualMarkerPath = new List <string>(actualMarkerIdPath.Count); foreach (var id in actualMarkerIdPath) { if ((frameDataView.GetMarkerFlags(id) & Unity.Profiling.LowLevel.MarkerFlags.AvailabilityEditor) != 0) { actualMarkerPath.Add(string.Format("EditorOnly [{0}]", frameDataView.GetMarkerName(id))); } else { actualMarkerPath.Add(frameDataView.GetMarkerName(id)); } } // admittedly, it'd be nice to only generate the text if sample selection option was chosen... // however, that would need to happen in an OnGui call and not within the callback of the generic menu, // to be able to calculate the needed window size and avoid glitches on first displaying it. // at least the user already clicked on the dropdown for this... string selectedSampleStackText = null; var sampleStackSb = new System.Text.StringBuilder(); if (m_TreeView.proxySelectionInfo.nonProxySampleStack != null && m_TreeView.proxySelectionInfo.nonProxySampleStack.Count > 0) { for (int i = m_TreeView.proxySelectionInfo.nonProxySampleStack.Count - 1; i >= 0; i--) { sampleStackSb.AppendLine(m_TreeView.proxySelectionInfo.nonProxySampleStack[i]); } selectedSampleStackText = sampleStackSb.ToString(); } string actualSampleStackText = null; if (actualMarkerPath != null && actualMarkerPath.Count > 0) { sampleStackSb.Clear(); for (int i = actualMarkerPath.Count - 1; i >= 0; i--) { sampleStackSb.AppendLine(actualMarkerPath[i]); } actualSampleStackText = sampleStackSb.ToString(); } var selectionSampleStackContent = selectedSampleStackText != null ? new GUIContent(selectedSampleStackText) : null; var actualSampleStackContent = actualSampleStackText != null ? new GUIContent(actualSampleStackText) : null; var sampleStackWindowSize = SelectedSampleStackWindow.CalculateSize(selectionSampleStackContent, actualSampleStackContent); menu.AddItem(BaseStyles.showSelectedSampleStacks, false, () => { SelectedSampleStackWindow.ShowSampleStackWindow(GUIUtility.GUIToScreenRect(rectForSampleStackButton).position, sampleStackWindowSize, selectionSampleStackContent, actualSampleStackContent); }); menu.DropDown(rectForSampleStackButton); } } GUILayout.EndHorizontal(); } } GUILayout.EndVertical(); if (showDetailedView) { GUILayout.BeginVertical(); // Detailed view area EditorGUILayout.BeginHorizontal(BaseStyles.toolbar); DrawDetailedViewPopup(); GUILayout.FlexibleSpace(); cpuModule.DrawOptionsMenuPopup(); EditorGUILayout.EndHorizontal(); switch (m_DetailedViewType) { case DetailedViewType.Objects: detailedObjectsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection()); break; case DetailedViewType.CallersAndCallees: detailedCallsView.DoGUI(BaseStyles.header, frameDataView, m_TreeView.GetSelection()); break; } GUILayout.EndVertical(); SplitterGUILayout.EndHorizontalSplit(); } HandleKeyboardEvents(); } }
private static extern IntPtr Internal_Create(ProfilerViewType viewType, int frameIndex, int threadIndex, ProfilerColumn profilerSortColumn, bool sortAscending, FrameViewFilteringModes collapseEditorSamples);
private static extern IntPtr Internal_Create(ProfilerViewType viewType, int frameIndex, int threadIndex, ProfilerColumn profilerSortColumn, bool sortAscending);
private void DrawCPUOrRenderingToolbar(ProfilerProperty property) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); this.m_ViewType = (ProfilerViewType) EditorGUILayout.IntPopup((int) this.m_ViewType, new string[3] { "Hierarchy", "Timeline", "Raw Hierarchy" }, new int[3]{ 0, 1, 2 }, EditorStyles.toolbarDropDown, new GUILayoutOption[1] { GUILayout.Width(100f) }); GUILayout.FlexibleSpace(); GUILayout.Label(string.Format("CPU:{0}ms GPU:{1}ms", (object) property.frameTime, (object) property.frameGpuTime), EditorStyles.miniLabel, new GUILayoutOption[0]); GUI.enabled = ProfilerDriver.GetNextFrameIndex(this.m_CurrentFrame) == -1; if (GUILayout.Button(!GUI.enabled ? ProfilerWindow.ms_Styles.noFrameDebugger : ProfilerWindow.ms_Styles.frameDebugger, EditorStyles.toolbarButton, new GUILayoutOption[0])) FrameDebuggerWindow.ShowFrameDebuggerWindow().EnableIfNeeded(); GUI.enabled = true; if (ProfilerInstrumentationPopup.InstrumentationEnabled && GUILayout.Button(ProfilerWindow.ms_Styles.profilerInstrumentation, EditorStyles.toolbarDropDown, new GUILayoutOption[0])) ProfilerInstrumentationPopup.Show(GUILayoutUtility.topLevel.GetLast()); GUILayout.FlexibleSpace(); this.SearchFieldGUI(); EditorGUILayout.EndHorizontal(); this.HandleCommandEvents(); }