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 override void DrawView(Rect position) { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar); ProfilerAudioView newShowDetailedAudioPane = m_ShowDetailedAudioPane; if (AudioDeepProfileToggle()) { if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Channels, "Channels", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Channels; } if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Groups, "Groups", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Groups; } if (GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.ChannelsAndGroups, "Channels and groups", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.ChannelsAndGroups; } if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.DSPGraph, "DSP Graph", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.DSPGraph; } if (Unsupported.IsDeveloperMode() && GUILayout.Toggle(newShowDetailedAudioPane == ProfilerAudioView.Clips, "Clips", EditorStyles.toolbarButton)) { newShowDetailedAudioPane = ProfilerAudioView.Clips; } if (newShowDetailedAudioPane != m_ShowDetailedAudioPane) { m_ShowDetailedAudioPane = newShowDetailedAudioPane; m_LastAudioProfilerFrame = -1; // force update } if (m_ShowDetailedAudioPane == ProfilerAudioView.DSPGraph) { m_ShowInactiveDSPChains = GUILayout.Toggle(m_ShowInactiveDSPChains, "Show inactive", EditorStyles.toolbarButton); if (m_ShowInactiveDSPChains) { m_HighlightAudibleDSPChains = GUILayout.Toggle(m_HighlightAudibleDSPChains, "Highlight audible", EditorStyles.toolbarButton); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var graphRect = DrawAudioStatsPane(ref m_PaneScroll_AudioDSPLeft); m_PaneScroll_AudioDSPRight = GUI.BeginScrollView(graphRect, m_PaneScroll_AudioDSPRight, new Rect(0, 0, 10000, 20000)); var clippingRect = new Rect(m_PaneScroll_AudioDSPRight.x, m_PaneScroll_AudioDSPRight.y, graphRect.width, graphRect.height); if (m_AudioProfilerDSPView == null) { m_AudioProfilerDSPView = new AudioProfilerDSPView(); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { m_AudioProfilerDSPView.OnGUI(clippingRect, property, m_ShowInactiveDSPChains, m_HighlightAudibleDSPChains, ref m_DSPGraphZoomFactor, ref m_PaneScroll_AudioDSPRight); } if (property != null) { property.Dispose(); } GUI.EndScrollView(); m_ProfilerWindow.Repaint(); } else if (m_ShowDetailedAudioPane == ProfilerAudioView.Clips) { GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioClips); // TREE if (m_AudioProfilerClipTreeViewState == null) { m_AudioProfilerClipTreeViewState = new AudioProfilerClipTreeViewState(); } if (m_AudioProfilerClipViewBackend == null) { m_AudioProfilerClipViewBackend = new AudioProfilerClipViewBackend(m_AudioProfilerClipTreeViewState); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex(); if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame) { m_LastAudioProfilerFrame = currentFrame; var sourceItems = property.GetAudioProfilerClipInfo(); if (sourceItems != null && sourceItems.Length > 0) { var items = new List <AudioProfilerClipInfoWrapper>(); foreach (var s in sourceItems) { items.Add(new AudioProfilerClipInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset))); } m_AudioProfilerClipViewBackend.SetData(items); if (m_AudioProfilerClipView == null) { m_AudioProfilerClipView = new AudioProfilerClipView(m_ProfilerWindow as EditorWindow, m_AudioProfilerClipTreeViewState); m_AudioProfilerClipView.Init(treeRect, m_AudioProfilerClipViewBackend); } } } if (m_AudioProfilerClipView != null) { m_AudioProfilerClipView.OnGUI(treeRect); } } if (property != null) { property.Dispose(); } } else { bool resetAllAudioClipPlayCountsOnPlay = GUILayout.Toggle(AudioUtil.resetAllAudioClipPlayCountsOnPlay, "Reset play count on play", EditorStyles.toolbarButton); if (resetAllAudioClipPlayCountsOnPlay != AudioUtil.resetAllAudioClipPlayCountsOnPlay) { AudioUtil.resetAllAudioClipPlayCountsOnPlay = resetAllAudioClipPlayCountsOnPlay; } if (Unsupported.IsDeveloperMode()) { GUILayout.Space(5); bool showAllGroups = EditorPrefs.GetBool("AudioProfilerShowAllGroups"); bool newShowAllGroups = GUILayout.Toggle(showAllGroups, "Show all groups (dev mode only)", EditorStyles.toolbarButton); if (showAllGroups != newShowAllGroups) { EditorPrefs.SetBool("AudioProfilerShowAllGroups", newShowAllGroups); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); var treeRect = DrawAudioStatsPane(ref m_PaneScroll_AudioChannels); // TREE if (m_AudioProfilerGroupTreeViewState == null) { m_AudioProfilerGroupTreeViewState = new AudioProfilerGroupTreeViewState(); } if (m_AudioProfilerGroupViewBackend == null) { m_AudioProfilerGroupViewBackend = new AudioProfilerGroupViewBackend(m_AudioProfilerGroupTreeViewState); } ProfilerProperty property = m_ProfilerWindow.CreateProperty(); if (CheckFrameData(property)) { var currentFrame = m_ProfilerWindow.GetActiveVisibleFrameIndex(); if (currentFrame == -1 || m_LastAudioProfilerFrame != currentFrame) { m_LastAudioProfilerFrame = currentFrame; var sourceItems = property.GetAudioProfilerGroupInfo(); if (sourceItems != null && sourceItems.Length > 0) { var items = new List <AudioProfilerGroupInfoWrapper>(); foreach (var s in sourceItems) { bool isGroup = (s.flags & AudioProfilerGroupInfoHelper.AUDIOPROFILER_FLAGS_GROUP) != 0; if (m_ShowDetailedAudioPane == ProfilerAudioView.Channels && isGroup) { continue; } if (m_ShowDetailedAudioPane == ProfilerAudioView.Groups && !isGroup) { continue; } items.Add(new AudioProfilerGroupInfoWrapper(s, property.GetAudioProfilerNameByOffset(s.assetNameOffset), property.GetAudioProfilerNameByOffset(s.objectNameOffset), m_ShowDetailedAudioPane == ProfilerAudioView.Channels)); } m_AudioProfilerGroupViewBackend.SetData(items); if (m_AudioProfilerGroupView == null) { m_AudioProfilerGroupView = new AudioProfilerGroupView(m_ProfilerWindow as EditorWindow, m_AudioProfilerGroupTreeViewState); m_AudioProfilerGroupView.Init(treeRect, m_AudioProfilerGroupViewBackend); } } } if (m_AudioProfilerGroupView != null) { m_AudioProfilerGroupView.OnGUI(treeRect, m_ShowDetailedAudioPane == ProfilerAudioView.Channels); } } if (property != null) { property.Dispose(); } } } else { GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); DrawOverviewText(ProfilerArea.Audio, position); } }
private void DrawAudioPane() { EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, new GUILayoutOption[0]); ProfilerAudioView showDetailedAudioPane = this.m_ShowDetailedAudioPane; if (GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.Stats, "Stats", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.Stats; } if (GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.Channels, "Channels", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.Channels; } if (GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.Groups, "Groups", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.Groups; } if (GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.ChannelsAndGroups, "Channels and groups", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.ChannelsAndGroups; } if (Unsupported.IsDeveloperBuild() && GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.DSPGraph, "DSP Graph", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.DSPGraph; } if (Unsupported.IsDeveloperBuild() && GUILayout.Toggle(showDetailedAudioPane == ProfilerAudioView.Clips, "Clips", EditorStyles.toolbarButton, new GUILayoutOption[0])) { showDetailedAudioPane = ProfilerAudioView.Clips; } if (showDetailedAudioPane != this.m_ShowDetailedAudioPane) { this.m_ShowDetailedAudioPane = showDetailedAudioPane; this.m_LastAudioProfilerFrame = -1; } if (this.m_ShowDetailedAudioPane == ProfilerAudioView.Stats) { GUILayout.Space(5f); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); this.DrawOverviewText(this.m_CurrentArea); } else if (this.m_ShowDetailedAudioPane == ProfilerAudioView.DSPGraph) { GUILayout.Space(5f); this.AudioProfilerToggle(ProfilerCaptureFlags.DSPNodes); GUILayout.Space(5f); this.m_ShowInactiveDSPChains = GUILayout.Toggle(this.m_ShowInactiveDSPChains, "Show inactive", EditorStyles.toolbarButton, new GUILayoutOption[0]); if (this.m_ShowInactiveDSPChains) { this.m_HighlightAudibleDSPChains = GUILayout.Toggle(this.m_HighlightAudibleDSPChains, "Highlight audible", EditorStyles.toolbarButton, new GUILayoutOption[0]); } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); Rect position = GUILayoutUtility.GetRect(20f, 10000f, (float) 10f, (float) 20000f); this.m_PaneScroll_AudioDSP = GUI.BeginScrollView(position, this.m_PaneScroll_AudioDSP, new Rect(0f, 0f, 10000f, 20000f)); Rect clippingRect = new Rect(this.m_PaneScroll_AudioDSP.x, this.m_PaneScroll_AudioDSP.y, position.width, position.height); if (this.m_AudioProfilerDSPView == null) { this.m_AudioProfilerDSPView = new AudioProfilerDSPView(); } ProfilerProperty property = this.CreateProperty(false); if (CheckFrameData(property)) { this.m_AudioProfilerDSPView.OnGUI(clippingRect, property, this.m_ShowInactiveDSPChains, this.m_HighlightAudibleDSPChains, ref this.m_DSPGraphZoomFactor, ref this.m_PaneScroll_AudioDSP); } property.Cleanup(); GUI.EndScrollView(); base.Repaint(); } else if (this.m_ShowDetailedAudioPane == ProfilerAudioView.Clips) { GUILayout.Space(5f); this.AudioProfilerToggle(ProfilerCaptureFlags.Clips); GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); Rect rect3 = GUILayoutUtility.GetRect(20f, 20000f, (float) 10f, (float) 10000f); Rect rect4 = new Rect(rect3.x, rect3.y, 230f, rect3.height); Rect rect = new Rect(rect4.xMax, rect3.y, rect3.width - rect4.width, rect3.height); string overviewText = ProfilerDriver.GetOverviewText(this.m_CurrentArea, this.GetActiveVisibleFrameIndex()); Vector2 vector = EditorStyles.wordWrappedLabel.CalcSize(GUIContent.Temp(overviewText)); this.m_PaneScroll_AudioClips = GUI.BeginScrollView(rect4, this.m_PaneScroll_AudioClips, new Rect(0f, 0f, vector.x, vector.y)); GUI.Label(new Rect(3f, 3f, vector.x, vector.y), overviewText, EditorStyles.wordWrappedLabel); GUI.EndScrollView(); EditorGUI.DrawRect(new Rect(rect4.xMax - 1f, rect4.y, 1f, rect4.height), Color.black); if (this.m_AudioProfilerClipTreeViewState == null) { this.m_AudioProfilerClipTreeViewState = new AudioProfilerClipTreeViewState(); } if (this.m_AudioProfilerClipViewBackend == null) { this.m_AudioProfilerClipViewBackend = new AudioProfilerClipViewBackend(this.m_AudioProfilerClipTreeViewState); } ProfilerProperty property2 = this.CreateProperty(false); if (CheckFrameData(property2)) { if ((this.m_CurrentFrame == -1) || (this.m_LastAudioProfilerFrame != this.m_CurrentFrame)) { this.m_LastAudioProfilerFrame = this.m_CurrentFrame; AudioProfilerClipInfo[] audioProfilerClipInfo = property2.GetAudioProfilerClipInfo(); if ((audioProfilerClipInfo != null) && (audioProfilerClipInfo.Length > 0)) { List<AudioProfilerClipInfoWrapper> data = new List<AudioProfilerClipInfoWrapper>(); foreach (AudioProfilerClipInfo info in audioProfilerClipInfo) { data.Add(new AudioProfilerClipInfoWrapper(info, property2.GetAudioProfilerNameByOffset(info.assetNameOffset))); } this.m_AudioProfilerClipViewBackend.SetData(data); if (this.m_AudioProfilerClipView == null) { this.m_AudioProfilerClipView = new AudioProfilerClipView(this, this.m_AudioProfilerClipTreeViewState); this.m_AudioProfilerClipView.Init(rect, this.m_AudioProfilerClipViewBackend); } } } if (this.m_AudioProfilerClipView != null) { this.m_AudioProfilerClipView.OnGUI(rect); } } property2.Cleanup(); } else { GUILayout.Space(5f); this.AudioProfilerToggle(ProfilerCaptureFlags.Channels); GUILayout.Space(5f); bool flag = GUILayout.Toggle(AudioUtil.resetAllAudioClipPlayCountsOnPlay, "Reset play count on play", EditorStyles.toolbarButton, new GUILayoutOption[0]); if (flag != AudioUtil.resetAllAudioClipPlayCountsOnPlay) { AudioUtil.resetAllAudioClipPlayCountsOnPlay = flag; } if (Unsupported.IsDeveloperBuild()) { GUILayout.Space(5f); bool @bool = EditorPrefs.GetBool("AudioProfilerShowAllGroups"); bool flag3 = GUILayout.Toggle(@bool, "Show all groups (dev-builds only)", EditorStyles.toolbarButton, new GUILayoutOption[0]); if (@bool != flag3) { EditorPrefs.SetBool("AudioProfilerShowAllGroups", flag3); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); Rect rect6 = GUILayoutUtility.GetRect(20f, 20000f, (float) 10f, (float) 10000f); Rect rect7 = new Rect(rect6.x, rect6.y, 230f, rect6.height); Rect rect8 = new Rect(rect7.xMax, rect6.y, rect6.width - rect7.width, rect6.height); string t = ProfilerDriver.GetOverviewText(this.m_CurrentArea, this.GetActiveVisibleFrameIndex()); Vector2 vector2 = EditorStyles.wordWrappedLabel.CalcSize(GUIContent.Temp(t)); this.m_PaneScroll_AudioChannels = GUI.BeginScrollView(rect7, this.m_PaneScroll_AudioChannels, new Rect(0f, 0f, vector2.x, vector2.y)); GUI.Label(new Rect(3f, 3f, vector2.x, vector2.y), t, EditorStyles.wordWrappedLabel); GUI.EndScrollView(); EditorGUI.DrawRect(new Rect(rect7.xMax - 1f, rect7.y, 1f, rect7.height), Color.black); if (this.m_AudioProfilerGroupTreeViewState == null) { this.m_AudioProfilerGroupTreeViewState = new AudioProfilerGroupTreeViewState(); } if (this.m_AudioProfilerGroupViewBackend == null) { this.m_AudioProfilerGroupViewBackend = new AudioProfilerGroupViewBackend(this.m_AudioProfilerGroupTreeViewState); } ProfilerProperty property3 = this.CreateProperty(false); if (CheckFrameData(property3)) { if ((this.m_CurrentFrame == -1) || (this.m_LastAudioProfilerFrame != this.m_CurrentFrame)) { this.m_LastAudioProfilerFrame = this.m_CurrentFrame; AudioProfilerGroupInfo[] audioProfilerGroupInfo = property3.GetAudioProfilerGroupInfo(); if ((audioProfilerGroupInfo != null) && (audioProfilerGroupInfo.Length > 0)) { List<AudioProfilerGroupInfoWrapper> list2 = new List<AudioProfilerGroupInfoWrapper>(); foreach (AudioProfilerGroupInfo info2 in audioProfilerGroupInfo) { bool flag4 = (info2.flags & 0x40) != 0; if (((this.m_ShowDetailedAudioPane != ProfilerAudioView.Channels) || !flag4) && ((this.m_ShowDetailedAudioPane != ProfilerAudioView.Groups) || flag4)) { list2.Add(new AudioProfilerGroupInfoWrapper(info2, property3.GetAudioProfilerNameByOffset(info2.assetNameOffset), property3.GetAudioProfilerNameByOffset(info2.objectNameOffset), this.m_ShowDetailedAudioPane == ProfilerAudioView.Channels)); } } this.m_AudioProfilerGroupViewBackend.SetData(list2); if (this.m_AudioProfilerGroupView == null) { this.m_AudioProfilerGroupView = new AudioProfilerGroupView(this, this.m_AudioProfilerGroupTreeViewState); this.m_AudioProfilerGroupView.Init(rect8, this.m_AudioProfilerGroupViewBackend); } } } if (this.m_AudioProfilerGroupView != null) { this.m_AudioProfilerGroupView.OnGUI(rect8, this.m_ShowDetailedAudioPane == ProfilerAudioView.Channels); } } property3.Cleanup(); } }