Skip to content

Commit e9b9c29

Browse files
author
Jan Reinhardt
committed
Refactored UAudioManager to match coding conventions
1 parent 6a4dea0 commit e9b9c29

File tree

13 files changed

+267
-267
lines changed

13 files changed

+267
-267
lines changed

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ MonoBehaviour:
136136
m_Script: {fileID: 11500000, guid: 88e5a9c38f6989249b88204932d7884f, type: 3}
137137
m_Name:
138138
m_EditorClassIdentifier:
139-
events:
139+
Events:
140140
- Name: Laser
141141
Spatialization: 0
142142
RoomSize: 0
@@ -247,16 +247,16 @@ MonoBehaviour:
247247
InstanceTimeBuffer: 0
248248
AudioEventInstanceBehavior: 0
249249
Container:
250-
containerType: 0
251-
looping: 0
252-
loopTime: 0
253-
sounds:
254-
- sound: {fileID: 8300000, guid: 25f57a423322f5a45bf9490fe9d13300, type: 3}
255-
looping: 0
256-
delayCenter: 0
257-
delayRandomization: 0
258-
crossfadeTime: 0
259-
currentClip: 0
250+
ContainerType: 0
251+
Looping: 0
252+
LoopTime: 0
253+
Sounds:
254+
- Sound: {fileID: 8300000, guid: 25f57a423322f5a45bf9490fe9d13300, type: 3}
255+
Looping: 0
256+
DelayCenter: 0
257+
DelayRandomization: 0
258+
CrossfadeTime: 0
259+
CurrentClip: 0
260260
- Name: Vocals
261261
Spatialization: 0
262262
RoomSize: 0
@@ -367,16 +367,16 @@ MonoBehaviour:
367367
InstanceTimeBuffer: 0
368368
AudioEventInstanceBehavior: 0
369369
Container:
370-
containerType: 0
371-
looping: 0
372-
loopTime: 0
373-
sounds:
374-
- sound: {fileID: 8300000, guid: aa9275dc39fa76144bcdb5c329400abe, type: 3}
375-
looping: 0
376-
delayCenter: 0
377-
delayRandomization: 0
378-
crossfadeTime: 0
379-
currentClip: 0
370+
ContainerType: 0
371+
Looping: 0
372+
LoopTime: 0
373+
Sounds:
374+
- Sound: {fileID: 8300000, guid: aa9275dc39fa76144bcdb5c329400abe, type: 3}
375+
Looping: 0
376+
DelayCenter: 0
377+
DelayRandomization: 0
378+
CrossfadeTime: 0
379+
CurrentClip: 0
380380
globalEventInstanceLimit: 0
381381
globalInstanceBehavior: 0
382382
--- !u!4 &69647939

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,19 @@ public string MessageOnAudioEnd
6767
private set;
6868
}
6969

70-
public AudioEvent audioEvent = null;
71-
public bool isStoppable = true;
72-
public float volDest = 1;
73-
public float altVolDest = 1;
74-
public float currentFade = 0;
75-
public bool playingAlt = false;
76-
public bool isActiveTimeComplete = false;
77-
public float activeTime = 0;
78-
public bool cancelEvent = false;
70+
public AudioEvent AudioEvent = null;
71+
public bool IsStoppable = true;
72+
public float VolDest = 1;
73+
public float AltVolDest = 1;
74+
public float CurrentFade = 0;
75+
public bool PlayingAlt = false;
76+
public bool IsActiveTimeComplete = false;
77+
public float ActiveTime = 0;
78+
public bool CancelEvent = false;
7979

8080
public ActiveEvent(AudioEvent audioEvent, GameObject emitter, AudioSource primarySource, AudioSource secondarySource, string messageOnAudioEnd = null)
8181
{
82-
this.audioEvent = audioEvent;
82+
this.AudioEvent = audioEvent;
8383
AudioEmitter = emitter;
8484
PrimarySource = primarySource;
8585
SecondarySource = secondarySource;
@@ -103,7 +103,7 @@ private void SetSourceProperties()
103103
}
104104
};
105105

106-
AudioEvent audioEvent = this.audioEvent;
106+
AudioEvent audioEvent = this.AudioEvent;
107107
switch (audioEvent.Spatialization)
108108
{
109109
case SpatialPositioningType.TwoD:
@@ -186,7 +186,7 @@ private void SetSourceProperties()
186186
if (audioEvent.FadeInTime > 0)
187187
{
188188
forEachSource((source) => source.volume = 0f);
189-
this.currentFade = audioEvent.FadeInTime;
189+
this.CurrentFade = audioEvent.FadeInTime;
190190
if (audioEvent.VolumeRandomization != 0)
191191
{
192192
vol = UnityEngine.Random.Range(audioEvent.VolumeCenter - audioEvent.VolumeRandomization, audioEvent.VolumeCenter + audioEvent.VolumeRandomization);
@@ -195,7 +195,7 @@ private void SetSourceProperties()
195195
{
196196
vol = audioEvent.VolumeCenter;
197197
}
198-
this.volDest = vol;
198+
this.VolDest = vol;
199199
}
200200
else
201201
{

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ namespace HoloToolkit.Unity
1111
[Serializable]
1212
public class UAudioClip
1313
{
14-
public UnityEngine.AudioClip sound = null;
15-
public bool looping = false;
14+
public UnityEngine.AudioClip Sound = null;
15+
public bool Looping = false;
1616

17-
public float delayCenter = 0;
18-
public float delayRandomization = 0;
17+
public float DelayCenter = 0;
18+
public float DelayRandomization = 0;
1919
}
2020
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ namespace HoloToolkit.Unity
1414
public class AudioContainer
1515
{
1616
[Tooltip("The type of the audio container.")]
17-
public AudioContainerType containerType = AudioContainerType.Random;
17+
public AudioContainerType ContainerType = AudioContainerType.Random;
1818

19-
public bool looping = false;
20-
public float loopTime = 0;
21-
public UAudioClip[] sounds = null;
22-
public float crossfadeTime = 0f;
23-
public int currentClip = 0;
19+
public bool Looping = false;
20+
public float LoopTime = 0;
21+
public UAudioClip[] Sounds = null;
22+
public float CrossfadeTime = 0f;
23+
public int CurrentClip = 0;
2424
}
2525
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ public class AudioEvent : IComparable, IComparable<AudioEvent>
158158
/// <returns>True if this AudioEvent's container is one of the continuous types (random or sequential), otherwise false.</returns>
159159
public bool IsContinuous()
160160
{
161-
return Container.containerType == AudioContainerType.ContinuousRandom ||
162-
Container.containerType == AudioContainerType.ContinuousSequence;
161+
return Container.ContainerType == AudioContainerType.ContinuousRandom ||
162+
Container.ContainerType == AudioContainerType.ContinuousSequence;
163163
}
164164

165165
/// <summary>

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

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace HoloToolkit.Unity
99
{
1010
public class UAudioManagerBaseEditor<TEvent> : Editor where TEvent : AudioEvent, new()
1111
{
12-
protected UAudioManagerBase<TEvent> myTarget;
12+
protected UAudioManagerBase<TEvent> MyTarget;
1313
private string[] eventNames;
1414
private int selectedEventIndex = 0;
1515
private readonly string[] posTypes = { "2D", "3D", "Spatial Sound" };
@@ -18,37 +18,37 @@ namespace HoloToolkit.Unity
1818
protected void SetUpEditor()
1919
{
2020
// Having a null array of events causes too many errors and should only happen on first adding anyway.
21-
if (this.myTarget.EditorEvents == null)
21+
if (this.MyTarget.EditorEvents == null)
2222
{
23-
this.myTarget.EditorEvents = new TEvent[0];
23+
this.MyTarget.EditorEvents = new TEvent[0];
2424
}
25-
this.eventNames = new string[this.myTarget.EditorEvents.Length];
26-
UpdateEventNames(this.myTarget.EditorEvents);
25+
this.eventNames = new string[this.MyTarget.EditorEvents.Length];
26+
UpdateEventNames(this.MyTarget.EditorEvents);
2727
}
2828

2929
protected void DrawInspectorGUI(bool showEmitters)
3030
{
3131
this.serializedObject.Update();
3232
EditorGUI.BeginChangeCheck();
33-
DrawEventHeader(this.myTarget.EditorEvents);
33+
DrawEventHeader(this.MyTarget.EditorEvents);
3434

35-
if (this.myTarget.EditorEvents != null && this.myTarget.EditorEvents.Length > 0)
35+
if (this.MyTarget.EditorEvents != null && this.MyTarget.EditorEvents.Length > 0)
3636
{
3737
// Display current event in dropdown.
3838
EditorGUI.indentLevel++;
3939
this.selectedEventIndex = EditorGUILayout.Popup(this.selectedEventIndex, this.eventNames);
4040

41-
if (this.selectedEventIndex < this.myTarget.EditorEvents.Length)
41+
if (this.selectedEventIndex < this.MyTarget.EditorEvents.Length)
4242
{
4343
TEvent selectedEvent;
4444

45-
selectedEvent = this.myTarget.EditorEvents[this.selectedEventIndex];
46-
SerializedProperty selectedEventProperty = this.serializedObject.FindProperty("events.Array.data[" + this.selectedEventIndex.ToString() + "]");
45+
selectedEvent = this.MyTarget.EditorEvents[this.selectedEventIndex];
46+
SerializedProperty selectedEventProperty = this.serializedObject.FindProperty("Events.Array.data[" + this.selectedEventIndex.ToString() + "]");
4747
EditorGUILayout.Space();
4848

4949
if (selectedEventProperty != null)
5050
{
51-
DrawEventInspector(selectedEventProperty, selectedEvent, this.myTarget.EditorEvents, showEmitters);
51+
DrawEventInspector(selectedEventProperty, selectedEvent, this.MyTarget.EditorEvents, showEmitters);
5252
if (!DrawContainerInspector(selectedEventProperty, selectedEvent))
5353
{
5454
EditorGUI.indentLevel++;
@@ -66,7 +66,7 @@ protected void DrawInspectorGUI(bool showEmitters)
6666

6767
if (UnityEngine.GUI.changed)
6868
{
69-
EditorUtility.SetDirty(this.myTarget);
69+
EditorUtility.SetDirty(this.MyTarget);
7070
}
7171
}
7272

@@ -81,13 +81,13 @@ private void DrawEventHeader(TEvent[] EditorEvents)
8181
{
8282
if (EditorGUILayoutExtensions.Button("Remove"))
8383
{
84-
this.myTarget.EditorEvents = RemoveAudioEvent(EditorEvents, this.selectedEventIndex);
84+
this.MyTarget.EditorEvents = RemoveAudioEvent(EditorEvents, this.selectedEventIndex);
8585
}
8686
}
8787

8888
if (EditorGUILayoutExtensions.Button("Add"))
8989
{
90-
this.myTarget.EditorEvents = AddAudioEvent(EditorEvents);
90+
this.MyTarget.EditorEvents = AddAudioEvent(EditorEvents);
9191
}
9292

9393
EditorGUILayout.EndHorizontal();
@@ -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

193-
if (selectedEvent.Container.looping)
193+
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();
@@ -220,7 +220,7 @@ private bool DrawContainerInspector(SerializedProperty selectedEventProperty, TE
220220

221221
private void DrawSoundClipInspector(SerializedProperty selectedEventProperty, TEvent selectedEvent)
222222
{
223-
bool allowLoopingClip = !selectedEvent.Container.looping;
223+
bool allowLoopingClip = !selectedEvent.Container.Looping;
224224

225225
if (allowLoopingClip)
226226
{
@@ -230,15 +230,15 @@ private void DrawSoundClipInspector(SerializedProperty selectedEventProperty, TE
230230
}
231231
}
232232

233-
for (int i = 0; i < selectedEvent.Container.sounds.Length; i++)
233+
for (int i = 0; i < selectedEvent.Container.Sounds.Length; i++)
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,23 +247,23 @@ 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

259-
if (selectedEvent.Container.sounds[i].looping && selectedEvent.Container.containerType == AudioContainerType.Simultaneous)
259+
if (selectedEvent.Container.Sounds[i].Looping && selectedEvent.Container.ContainerType == AudioContainerType.Simultaneous)
260260
{
261261
allowLoopingClip = false;
262262
}
263263
}
264264
else
265265
{
266-
selectedEvent.Container.sounds[i].looping = false;
266+
selectedEvent.Container.Sounds[i].Looping = false;
267267
}
268268
}
269269
}
@@ -293,18 +293,18 @@ private void UpdateEventNames(TEvent[] EditorEvents)
293293
private void AddSound(TEvent selectedEvent)
294294
{
295295

296-
UAudioClip[] tempClips = new UAudioClip[selectedEvent.Container.sounds.Length + 1];
297-
selectedEvent.Container.sounds.CopyTo(tempClips, 0);
296+
UAudioClip[] tempClips = new UAudioClip[selectedEvent.Container.Sounds.Length + 1];
297+
selectedEvent.Container.Sounds.CopyTo(tempClips, 0);
298298
tempClips[tempClips.Length - 1] = new UAudioClip();
299-
selectedEvent.Container.sounds = tempClips;
299+
selectedEvent.Container.Sounds = tempClips;
300300
}
301301

302302
private TEvent[] AddAudioEvent(TEvent[] EditorEvents)
303303
{
304304
TEvent tempEvent = new TEvent();
305305
TEvent[] tempEventArray = new TEvent[EditorEvents.Length + 1];
306306
tempEvent.Container = new AudioContainer();
307-
tempEvent.Container.sounds = new UAudioClip[0];
307+
tempEvent.Container.Sounds = new UAudioClip[0];
308308
EditorEvents.CopyTo(tempEventArray, 0);
309309
tempEventArray[EditorEvents.Length] = tempEvent;
310310
this.eventNames = new string[tempEventArray.Length];

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class UAudioManagerEditor : UAudioManagerBaseEditor<AudioEvent>
1010
{
1111
private void OnEnable()
1212
{
13-
this.myTarget = (UAudioManager)target;
13+
this.MyTarget = (UAudioManager)target;
1414
SetUpEditor();
1515
}
1616

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class UAudioMiniManagerEditor : UAudioManagerBaseEditor<MiniAudioEvent>
1010
{
1111
private void OnEnable()
1212
{
13-
this.myTarget = (UAudioMiniManager)target;
13+
this.MyTarget = (UAudioMiniManager)target;
1414
SetUpEditor();
1515
}
1616

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ private void CollectProfilerEvents(ProfilerEvent[] currentEvents)
6565
{
6666
ActiveEvent currentEvent = activeEvents[i];
6767
ProfilerEvent tempEvent = new ProfilerEvent();
68-
tempEvent.EventName = currentEvent.audioEvent.Name;
68+
tempEvent.EventName = currentEvent.AudioEvent.Name;
6969
tempEvent.EmitterName = currentEvent.AudioEmitter.name;
7070

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

8181
currentEvents[i] = tempEvent;

0 commit comments

Comments
 (0)