Skip to content

Commit 3b3e0b2

Browse files
author
Jan Reinhardt
committed
Fixed UAudioManager Editor Bug and added Test Scene for UAudioManager
1 parent f041cda commit 3b3e0b2

File tree

9 files changed

+666
-37
lines changed

9 files changed

+666
-37
lines changed

Assets/HoloToolkit-Tests/SpatialSound/Scenes/UAudioManagerTest.unity

Lines changed: 573 additions & 0 deletions
Large diffs are not rendered by default.

Assets/HoloToolkit-Tests/SpatialSound/Scenes/UAudioManagerTest.unity.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/HoloToolkit-Tests/SpatialSound/Scripts.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections;
3+
using HoloToolkit.Unity;
4+
using UnityEngine;
5+
6+
public class UAudioManagerTest : MonoBehaviour
7+
{
8+
void Start ()
9+
{
10+
StartCoroutine(ContinouslyPlaySounds());
11+
}
12+
13+
private IEnumerator ContinouslyPlaySounds()
14+
{
15+
while (true)
16+
{
17+
UAudioManager.Instance.PlayEvent("Laser");
18+
19+
yield return new WaitForSeconds(1.0f);
20+
21+
UAudioManager.Instance.PlayEvent("Vocals");
22+
23+
yield return new WaitForSeconds(10.0f);
24+
}
25+
}
26+
27+
}

Assets/HoloToolkit-Tests/SpatialSound/Scripts/UAudioManagerTest.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/ActiveEvent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,9 @@ private void SetSourceProperties()
165165
});
166166
}
167167

168-
if (audioEvent.Bus != null)
168+
if (audioEvent.AudioBus != null)
169169
{
170-
forEachSource((source) => source.outputAudioMixerGroup = audioEvent.Bus);
170+
forEachSource((source) => source.outputAudioMixerGroup = audioEvent.AudioBus);
171171
}
172172

173173
float pitch = 1f;

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/AudioEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public class AudioEvent : IComparable, IComparable<AudioEvent>
9494
public float UnityGainDistance = SpatialSoundSettings.DefaultUnityGainDistance;
9595

9696
[Tooltip("The AudioMixerGroup to use when playing.")]
97-
public AudioMixerGroup Bus;
97+
public AudioMixerGroup AudioBus;
9898

9999
[Tooltip("The default or center pitch around which randomization can be done.")]
100100
[Range(-3.0f, 3.0f)]

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/Editor/UAudioManagerBaseEditor.cs

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private void DrawEventHeader(TEvent[] EditorEvents)
9797
private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent selectedEvent, TEvent[] EditorEvents, bool showEmitters)
9898
{
9999
// Get current event's properties.
100-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("name"));
100+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Name"));
101101

102102
if (selectedEvent.Name != this.eventNames[this.selectedEventIndex])
103103
{
@@ -106,10 +106,10 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent
106106

107107
if (showEmitters)
108108
{
109-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("primarySource"));
109+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("PrimarySource"));
110110
if (selectedEvent.IsContinuous())
111111
{
112-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("secondarySource"));
112+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("SecondarySource"));
113113
}
114114
}
115115

@@ -118,10 +118,10 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent
118118

119119
if (selectedEvent.Spatialization == SpatialPositioningType.SpatialSound)
120120
{
121-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("roomSize"));
122-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("minGain"));
123-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxGain"));
124-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("unityGainDistance"));
121+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("RoomSize"));
122+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("MinGain"));
123+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("MaxGain"));
124+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("UnityGainDistance"));
125125
EditorGUILayout.Space();
126126
}
127127
else if (selectedEvent.Spatialization == SpatialPositioningType.ThreeD)
@@ -133,49 +133,49 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent
133133
float curveWidth = 300f;
134134

135135
//Simple 3D Sounds properties
136-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxDistanceAttenuation3D"));
136+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("MaxDistanceAttenuation3D"));
137137

138138
//volume attenuation
139-
selectedEventProperty.FindPropertyRelative("attenuationCurve").animationCurveValue = EditorGUILayout.CurveField("Attenuation", selectedEventProperty.FindPropertyRelative("attenuationCurve").animationCurveValue, Color.red, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
139+
selectedEventProperty.FindPropertyRelative("AttenuationCurve").animationCurveValue = EditorGUILayout.CurveField("Attenuation", selectedEventProperty.FindPropertyRelative("attenuationCurve").animationCurveValue, Color.red, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
140140
//Spatial green
141-
selectedEventProperty.FindPropertyRelative("spatialCurve").animationCurveValue = EditorGUILayout.CurveField("Spatial", selectedEventProperty.FindPropertyRelative("spatialCurve").animationCurveValue, Color.green, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
141+
selectedEventProperty.FindPropertyRelative("SpatialCurve").animationCurveValue = EditorGUILayout.CurveField("Spatial", selectedEventProperty.FindPropertyRelative("spatialCurve").animationCurveValue, Color.green, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
142142
//spread lightblue
143-
selectedEventProperty.FindPropertyRelative("spreadCurve").animationCurveValue = EditorGUILayout.CurveField("Spread", selectedEventProperty.FindPropertyRelative("spreadCurve").animationCurveValue, Color.blue, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
143+
selectedEventProperty.FindPropertyRelative("SpreadCurve").animationCurveValue = EditorGUILayout.CurveField("Spread", selectedEventProperty.FindPropertyRelative("spreadCurve").animationCurveValue, Color.blue, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
144144
//lowpass purple
145-
selectedEventProperty.FindPropertyRelative("lowPassCurve").animationCurveValue = EditorGUILayout.CurveField("LowPass", selectedEventProperty.FindPropertyRelative("lowPassCurve").animationCurveValue, Color.magenta, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
145+
selectedEventProperty.FindPropertyRelative("LowPassCurve").animationCurveValue = EditorGUILayout.CurveField("LowPass", selectedEventProperty.FindPropertyRelative("lowPassCurve").animationCurveValue, Color.magenta, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
146146
//Yellow reverb
147-
selectedEventProperty.FindPropertyRelative("reverbCurve").animationCurveValue = EditorGUILayout.CurveField("Reverb", selectedEventProperty.FindPropertyRelative("reverbCurve").animationCurveValue, Color.yellow, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
147+
selectedEventProperty.FindPropertyRelative("ReverbCurve").animationCurveValue = EditorGUILayout.CurveField("Reverb", selectedEventProperty.FindPropertyRelative("reverbCurve").animationCurveValue, Color.yellow, editorCurveSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
148148

149149
EditorGUILayout.Space();
150150
}
151151

152-
// Bus
153-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("bus"));
152+
// AudioBus
153+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("AudioBus"));
154154

155155
// Fades
156156
if (!selectedEvent.IsContinuous())
157157
{
158-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("fadeInTime"));
159-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("fadeOutTime"));
158+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("FadeInTime"));
159+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("FadeOutTime"));
160160
}
161161

162162
// Pitch Settings
163-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("pitchCenter"));
163+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("PitchCenter"));
164164

165165
// Volume settings
166-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("volumeCenter"));
166+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("VolumeCenter"));
167167

168168
// Pan Settings
169169
if (selectedEvent.Spatialization == SpatialPositioningType.TwoD)
170170
{
171-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("panCenter"));
171+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("PanCenter"));
172172
}
173173
// Instancing
174174
EditorGUILayout.BeginHorizontal();
175-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("instanceLimit"));
176-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("instanceTimeBuffer"));
175+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("InstanceLimit"));
176+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("InstanceTimeBuffer"));
177177
EditorGUILayout.EndHorizontal();
178-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("instanceBehavior"));
178+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("AudioEventInstanceBehavior"));
179179

180180
// Container
181181
EditorGUILayout.Space();
@@ -184,15 +184,15 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent
184184
private bool DrawContainerInspector(SerializedProperty selectedEventProperty, TEvent selectedEvent)
185185
{
186186
bool addedSound = false;
187-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.containerType"));
187+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.containerType"));
188188

189189
if (!selectedEvent.IsContinuous())
190190
{
191-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.looping"));
191+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.looping"));
192192

193193
if (selectedEvent.Container.looping)
194194
{
195-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.loopTime"));
195+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.loopTime"));
196196
}
197197
}
198198

@@ -201,7 +201,7 @@ private bool DrawContainerInspector(SerializedProperty selectedEventProperty, TE
201201

202202
if (selectedEvent.IsContinuous())
203203
{
204-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.crossfadeTime"));
204+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.crossfadeTime"));
205205
}
206206

207207
EditorGUILayout.BeginHorizontal();
@@ -234,11 +234,11 @@ private void DrawSoundClipInspector(SerializedProperty selectedEventProperty, TE
234234
{
235235
EditorGUILayout.Space();
236236
EditorGUILayout.BeginHorizontal();
237-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.sounds.Array.data[" + i + "].sound"));
237+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.sounds.Array.data[" + i + "].sound"));
238238

239239
if (EditorGUILayoutExtensions.Button("Remove"))
240240
{
241-
selectedEventProperty.FindPropertyRelative("container.sounds.Array.data[" + i + "]").DeleteCommand();
241+
selectedEventProperty.FindPropertyRelative("Container.sounds.Array.data[" + i + "]").DeleteCommand();
242242
break;
243243
}
244244

@@ -247,14 +247,14 @@ private void DrawSoundClipInspector(SerializedProperty selectedEventProperty, TE
247247
if (!selectedEvent.IsContinuous())
248248
{
249249
EditorGUILayout.BeginHorizontal();
250-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.sounds.Array.data[" + i + "].delayCenter"));
251-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.sounds.Array.data[" + i + "].delayRandomization"));
250+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.sounds.Array.data[" + i + "].delayCenter"));
251+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.sounds.Array.data[" + i + "].delayRandomization"));
252252
EditorGUILayout.EndHorizontal();
253253

254254
//Disable looping next clips in a simultaneous container only.
255255
if (allowLoopingClip)
256256
{
257-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("container.sounds.Array.data[" + i + "].looping"));
257+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("Container.sounds.Array.data[" + i + "].looping"));
258258

259259
if (selectedEvent.Container.sounds[i].looping && selectedEvent.Container.containerType == AudioContainerType.Simultaneous)
260260
{

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/Editor/UAudioProfiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,13 @@ private void CollectProfilerEvents(ProfilerEvent[] currentEvents)
6969
tempEvent.EmitterName = currentEvent.AudioEmitter.name;
7070

7171
// The bus might be null, Unity defaults to Editor-hidden master bus.
72-
if (currentEvent.audioEvent.Bus == null)
72+
if (currentEvent.audioEvent.AudioBus == null)
7373
{
7474
tempEvent.BusName = "-MasterBus-";
7575
}
7676
else
7777
{
78-
tempEvent.BusName = currentEvent.audioEvent.Bus.name;
78+
tempEvent.BusName = currentEvent.audioEvent.AudioBus.name;
7979
}
8080

8181
currentEvents[i] = tempEvent;

0 commit comments

Comments
 (0)