コード例 #1
0
 public void OnGUI(Rect clippingRect, ProfilerProperty property, bool showInactiveDSPChains, bool highlightAudibleDSPChains, ref float zoomFactor, ref Vector2 scrollPos)
 {
     if (Event.current.type == EventType.ScrollWheel && clippingRect.Contains(Event.current.mousePosition) && Event.current.shift)
     {
         float num  = 1.05f;
         float num2 = zoomFactor;
         zoomFactor *= ((Event.current.delta.y <= 0f) ? (1f / num) : num);
         scrollPos  += (Event.current.mousePosition - scrollPos) * (zoomFactor - num2);
         Event.current.Use();
     }
     else if (Event.current.type == EventType.Repaint)
     {
         int num3 = 64;
         int num4 = 16;
         int num5 = 140;
         int num6 = 30;
         int num7 = num3 + 10;
         int num8 = 5;
         Dictionary <int, AudioProfilerDSPView.AudioProfilerDSPNode> dictionary = new Dictionary <int, AudioProfilerDSPView.AudioProfilerDSPNode>();
         List <AudioProfilerDSPView.AudioProfilerDSPWire>            list       = new List <AudioProfilerDSPView.AudioProfilerDSPWire>();
         AudioProfilerDSPInfo[] audioProfilerDSPInfo = property.GetAudioProfilerDSPInfo();
         if (audioProfilerDSPInfo != null)
         {
             bool flag = true;
             AudioProfilerDSPInfo[] array = audioProfilerDSPInfo;
             for (int i = 0; i < array.Length; i++)
             {
                 AudioProfilerDSPInfo info = array[i];
                 if (showInactiveDSPChains || (info.flags & 1) != 0)
                 {
                     if (!dictionary.ContainsKey(info.id))
                     {
                         AudioProfilerDSPView.AudioProfilerDSPNode audioProfilerDSPNode = (!dictionary.ContainsKey(info.target)) ? null : dictionary[info.target];
                         if (audioProfilerDSPNode != null)
                         {
                             dictionary[info.id]        = new AudioProfilerDSPView.AudioProfilerDSPNode(audioProfilerDSPNode, info, audioProfilerDSPNode.x + num5 + num7, audioProfilerDSPNode.maxY, audioProfilerDSPNode.level + 1);
                             audioProfilerDSPNode.maxY += num6 + num8;
                             for (AudioProfilerDSPView.AudioProfilerDSPNode audioProfilerDSPNode2 = audioProfilerDSPNode; audioProfilerDSPNode2 != null; audioProfilerDSPNode2 = audioProfilerDSPNode2.firstTarget)
                             {
                                 audioProfilerDSPNode2.maxY = Mathf.Max(audioProfilerDSPNode2.maxY, audioProfilerDSPNode.maxY);
                             }
                         }
                         else if (flag)
                         {
                             flag = false;
                             dictionary[info.id] = new AudioProfilerDSPView.AudioProfilerDSPNode(audioProfilerDSPNode, info, 10 + num5 / 2, 10 + num6 / 2, 1);
                         }
                         if (audioProfilerDSPNode != null)
                         {
                             list.Add(new AudioProfilerDSPView.AudioProfilerDSPWire(dictionary[info.id], audioProfilerDSPNode, info));
                         }
                     }
                     else
                     {
                         list.Add(new AudioProfilerDSPView.AudioProfilerDSPWire(dictionary[info.id], dictionary[info.target], info));
                     }
                 }
             }
             foreach (KeyValuePair <int, AudioProfilerDSPView.AudioProfilerDSPNode> current in dictionary)
             {
                 AudioProfilerDSPView.AudioProfilerDSPNode value = current.Value;
                 value.y += ((value.maxY != value.y) ? (value.maxY - value.y) : (num6 + num8)) / 2;
             }
             foreach (AudioProfilerDSPView.AudioProfilerDSPWire current2 in list)
             {
                 float num9 = 4f;
                 AudioProfilerDSPView.AudioProfilerDSPNode source = current2.source;
                 AudioProfilerDSPView.AudioProfilerDSPNode target = current2.target;
                 AudioProfilerDSPInfo info2 = current2.info;
                 Vector3 vector             = new Vector3(((float)source.x - (float)num5 * 0.5f) * zoomFactor, (float)source.y * zoomFactor, 0f);
                 Vector3 vector2            = new Vector3(((float)target.x + (float)num5 * 0.5f) * zoomFactor, ((float)target.y + (float)current2.targetPort * num9) * zoomFactor, 0f);
                 int     outCode            = AudioProfilerDSPView.GetOutCode(vector, clippingRect);
                 int     outCode2           = AudioProfilerDSPView.GetOutCode(vector2, clippingRect);
                 if ((outCode & outCode2) == 0)
                 {
                     float width = 3f;
                     Handles.color = new Color(info2.weight, 0f, 0f, (highlightAudibleDSPChains && !source.audible) ? 0.4f : 1f);
                     Handles.DrawAAPolyLine(width, 2, new Vector3[]
                     {
                         vector,
                         vector2
                     });
                 }
             }
             foreach (AudioProfilerDSPView.AudioProfilerDSPWire current3 in list)
             {
                 AudioProfilerDSPView.AudioProfilerDSPNode source2 = current3.source;
                 AudioProfilerDSPView.AudioProfilerDSPNode target2 = current3.target;
                 AudioProfilerDSPInfo info3 = current3.info;
                 if (info3.weight != 1f)
                 {
                     int num10 = source2.x - (num7 + num5) / 2;
                     int num11 = (target2 == null) ? target2.y : ((int)((float)target2.y + ((float)(num10 - target2.x) - (float)num5 * 0.5f) * (float)(source2.y - target2.y) / (float)(source2.x - target2.x - num5)));
                     this.DrawRectClipped(new Rect((float)(num10 - num3 / 2), (float)(num11 - num4 / 2), (float)num3, (float)num4), new Color(1f, 0.3f, 0.2f, (highlightAudibleDSPChains && !source2.audible) ? 0.4f : 1f), string.Format("{0:0.00}%", 100f * info3.weight), clippingRect, zoomFactor);
                 }
             }
             foreach (KeyValuePair <int, AudioProfilerDSPView.AudioProfilerDSPNode> current4 in dictionary)
             {
                 AudioProfilerDSPView.AudioProfilerDSPNode value2 = current4.Value;
                 AudioProfilerDSPInfo info4 = value2.info;
                 if (dictionary.ContainsKey(info4.target) && value2.firstTarget == dictionary[info4.target])
                 {
                     string text  = property.GetAudioProfilerNameByOffset(info4.nameOffset);
                     float  num12 = 0.01f * info4.cpuLoad;
                     float  num13 = 0.1f;
                     bool   flag2 = (info4.flags & 1) != 0;
                     bool   flag3 = (info4.flags & 2) != 0;
                     Color  col   = new Color((flag2 && !flag3) ? Mathf.Clamp(2f * num13 * num12, 0f, 1f) : 0.5f, (flag2 && !flag3) ? Mathf.Clamp(2f - 2f * num13 * num12, 0f, 1f) : 0.5f, (!flag3) ? ((!flag2) ? 0.5f : 0f) : 1f, (highlightAudibleDSPChains && !value2.audible) ? 0.4f : 1f);
                     text  = text.Replace("ChannelGroup", "Group");
                     text  = text.Replace("FMOD Channel", "Channel");
                     text  = text.Replace("FMOD WaveTable Unit", "Wavetable");
                     text  = text.Replace("FMOD Resampler Unit", "Resampler");
                     text  = text.Replace("FMOD Channel DSPHead Unit", "Channel DSP");
                     text  = text.Replace("FMOD Channel DSPHead Unit", "Channel DSP");
                     text += string.Format(" ({0:0.00}%)", num12);
                     this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f, (float)value2.y - (float)num6 * 0.5f, (float)num5, (float)num6), col, text, clippingRect, zoomFactor);
                     if (value2.audible)
                     {
                         if (info4.numLevels >= 1)
                         {
                             float num14 = (float)(num6 - 6) * Mathf.Clamp(info4.level1, 0f, 1f);
                             this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 3f, (float)value2.y - (float)num6 * 0.5f + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor);
                             this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 3f, (float)value2.y - (float)num6 * 0.5f - 3f + (float)num6 - num14, 4f, num14), Color.red, null, clippingRect, zoomFactor);
                         }
                         if (info4.numLevels >= 2)
                         {
                             float num15 = (float)(num6 - 6) * Mathf.Clamp(info4.level2, 0f, 1f);
                             this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 8f, (float)value2.y - (float)num6 * 0.5f + 3f, 4f, (float)(num6 - 6)), Color.black, null, clippingRect, zoomFactor);
                             this.DrawRectClipped(new Rect((float)value2.x - (float)num5 * 0.5f + 8f, (float)value2.y - (float)num6 * 0.5f - 3f + (float)num6 - num15, 4f, num15), Color.red, null, clippingRect, zoomFactor);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 public AudioProfilerDSPWire(AudioProfilerDSPView.AudioProfilerDSPNode source, AudioProfilerDSPView.AudioProfilerDSPNode target, AudioProfilerDSPInfo info)
 {
     this.source = source;
     this.target = target;
     this.info = info;
     this.targetPort = target.targetPort;
 }
コード例 #3
0
 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();
     }
 }
コード例 #4
0
 public AudioProfilerDSPNode(AudioProfilerDSPView.AudioProfilerDSPNode firstTarget, AudioProfilerDSPInfo info, int x, int y, int level)
 {
     this.firstTarget = firstTarget;
     this.info = info;
     this.x = x;
     this.y = y;
     this.level = level;
     this.maxY = y;
     this.audible = ((info.flags & 1) != 0) && ((info.flags & 2) == 0);
     if (firstTarget != null)
     {
         this.audible &= firstTarget.audible;
     }
 }