AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
UAudioManagerBaseEditor.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using UnityEditor;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity
8 {
9  public class UAudioManagerBaseEditor<TEvent, TBank> : Editor where TEvent : AudioEvent, new() where TBank : AudioBank<TEvent>, new()
10  {
12 
13  public void DrawExportToAsset()
14  {
15  // Don't show this if there are no embedded events in this audio manager
16  if (MyTarget.EditorEvents == null || MyTarget.EditorEvents.Length == 0)
17  return;
18 
19  EditorGUILayout.HelpBox("Audio events have moved to an asset system.\nThey are no longer stored in the scene.\nPlease export these events to an event bank.", MessageType.Info, true);
20 
21  if (GUILayout.Button("Convert To Bank"))
22  {
23  TBank bank = ScriptableObject.CreateInstance<TBank>();
24 
25  bank.Events = MyTarget.EditorEvents;
26 
27  // Create the Asset
28  AssetDatabase.CreateAsset(bank, "Assets/ConvertedAudioBank.asset");
29  AssetDatabase.SaveAssets();
30 
31  // Remove the events from the manager
32  this.serializedObject.Update();
33  var eventsProperty = this.serializedObject.FindProperty("Events");
34  eventsProperty.ClearArray();
35 
36  // Add the Asset to the Default Banks
37  var defaultBanksProperty = this.serializedObject.FindProperty("DefaultBanks");
38  defaultBanksProperty.InsertArrayElementAtIndex(defaultBanksProperty.arraySize);
39  var newEntry = defaultBanksProperty.FindPropertyRelative("Array.data[" + (defaultBanksProperty.arraySize - 1) + "]");
40  newEntry.objectReferenceValue = bank;
41 
42  this.serializedObject.ApplyModifiedProperties();
43  }
44  }
45 
46  public void DrawBankList()
47  {
48  this.serializedObject.Update();
49  var bankList = this.serializedObject.FindProperty("DefaultBanks");
50 
51  EditorGUILayout.PropertyField(bankList, true);
52 
53  this.serializedObject.ApplyModifiedProperties();
54  }
55 
56  protected void SetUpEditor()
57  {
58  if (MyTarget.DefaultBanks == null)
59  {
60  MyTarget.DefaultBanks = new TBank[0];
61  }
62  }
63 
64  }
65 }
UAudioManagerBase provides the base functionality for UAudioManager classes.
UAudioManagerBase< TEvent, TBank > MyTarget
The AudioEvent class is the main component of UAudioManager and contains settings and a container for...
Definition: AudioEvent.cs:54
The audio bank contains a list of audio events that can be loaded into a UAudioManager for playback...
Definition: AudioBank.cs:11