4 using System.Collections.Generic;
12 private int currentFrame = 0;
13 private List<ProfilerEvent[]> eventTimeline;
14 private Vector2 scrollOffset =
new Vector2();
15 private const int MaxFrames = 300;
17 private class ProfilerEvent
19 public string EventName =
"";
20 public string EmitterName =
"";
21 public string BusName =
"";
24 [MenuItem(
"Mixed Reality Toolkit/UAudioTools/Profiler",
false, 200)]
25 static void ShowEditor()
28 if (profilerWindow.eventTimeline == null)
30 profilerWindow.currentFrame = 0;
31 profilerWindow.eventTimeline =
new List<ProfilerEvent[]>();
33 profilerWindow.Show();
37 private void OnInspectorUpdate()
39 if (!EditorApplication.isPlaying)
44 ProfilerEvent[] currentEvents =
new ProfilerEvent[0];
46 if (this.eventTimeline == null)
48 this.eventTimeline =
new List<ProfilerEvent[]>();
53 CollectProfilerEvents(currentEvents);
60 private void CollectProfilerEvents(ProfilerEvent[] currentEvents)
63 currentEvents =
new ProfilerEvent[activeEvents.Count];
64 for (
int i = 0; i < currentEvents.Length; i++)
67 ProfilerEvent tempEvent =
new ProfilerEvent();
74 tempEvent.BusName =
"-MasterBus-";
81 currentEvents[i] = tempEvent;
83 this.eventTimeline.Add(currentEvents);
86 if (this.eventTimeline.Count > MaxFrames)
88 this.eventTimeline.RemoveAt(0);
90 this.currentFrame = this.eventTimeline.Count - 1;
96 if (!EditorApplication.isPlaying)
103 if(eventTimeline!=null)
105 this.currentFrame = EditorGUILayout.IntSlider(this.currentFrame, 0, this.eventTimeline.Count - 1);
106 scrollOffset = EditorGUILayout.BeginScrollView(scrollOffset);
108 if (this.eventTimeline.Count >
this.currentFrame)
110 for (
int i = 0; i < this.eventTimeline[this.currentFrame].Length; i++)
112 DrawEventButton(this.eventTimeline[this.currentFrame][i], i);
116 EditorGUILayout.EndScrollView();
121 private void DrawEventButton(ProfilerEvent currentEvent,
int id)
123 EditorGUILayout.SelectableLabel(currentEvent.EventName +
"-->(" + currentEvent.EmitterName +
")-->(" + currentEvent.BusName +
")");