AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ButtonSoundProfile.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 HoloToolkit.Unity;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity.Buttons
8 {
10  {
11  // Direct interaction clips
13  public AudioClip ButtonCanceled;
15  public AudioClip ButtonHeld;
17  public AudioClip ButtonPressed;
19  public AudioClip ButtonReleased;
20 
21  // State change clips
23  public AudioClip ButtonObservation;
25  public AudioClip ButtonObservationTargeted;
27  public AudioClip ButtonTargeted;
28 
29  // Volumes
31  public float ButtonCanceledVolume = 1f;
33  public float ButtonHeldVolume = 1f;
35  public float ButtonPressedVolume = 1f;
37  public float ButtonReleasedVolume = 1f;
39  public float ButtonObservationVolume = 1f;
41  public float ButtonObservationTargetedVolume = 1f;
43  public float ButtonTargetedVolume = 1f;
44 
45 #if UNITY_EDITOR
46  [UnityEditor.CustomEditor(typeof(ButtonSoundProfile))]
47  public class CustomEditor : ProfileInspector
48  {
49  protected override void DrawCustomFooter() {
50  ButtonSoundProfile soundProfile = (ButtonSoundProfile)target;
51 
52  DrawClipEditor(ref soundProfile.ButtonPressed, ref soundProfile.ButtonPressedVolume, "Button Pressed");
53  DrawClipEditor(ref soundProfile.ButtonTargeted, ref soundProfile.ButtonTargetedVolume, "Button Targeted");
54  DrawClipEditor(ref soundProfile.ButtonHeld, ref soundProfile.ButtonHeldVolume, "Button Held");
55  DrawClipEditor(ref soundProfile.ButtonReleased, ref soundProfile.ButtonReleasedVolume, "Button Released");
56  DrawClipEditor(ref soundProfile.ButtonCanceled, ref soundProfile.ButtonCanceledVolume, "Button Canceled");
57  DrawClipEditor(ref soundProfile.ButtonObservation, ref soundProfile.ButtonObservationVolume, "Button Observation");
58  DrawClipEditor(ref soundProfile.ButtonObservationTargeted, ref soundProfile.ButtonObservationTargetedVolume, "Button Observation Targeted");
59  }
60 
61  protected void DrawClipEditor(ref AudioClip clip, ref float volume, string label) {
62  UnityEditor.EditorGUILayout.Space();
63  UnityEditor.EditorGUILayout.LabelField(label, UnityEditor.EditorStyles.boldLabel);
64  UnityEditor.EditorGUI.indentLevel++;
65  UnityEditor.EditorGUILayout.BeginHorizontal();
66  clip = (AudioClip)UnityEditor.EditorGUILayout.ObjectField(clip, typeof(UnityEngine.AudioClip), true);
67  volume = UnityEditor.EditorGUILayout.Slider(volume, 0f, 1f);
68  UnityEditor.EditorGUILayout.EndHorizontal();
69  UnityEditor.EditorGUI.indentLevel--;
70  }
71  }
72 #endif
73  }
74 }
The base class for all button profiles Inherit from this to create new button profile types ...