Skip to content

Commit 0c2d842

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Merge branch 'master' into HTK-local
2 parents 5467af7 + 4e20a8e commit 0c2d842

File tree

16 files changed

+794
-308
lines changed

16 files changed

+794
-308
lines changed

Assets/HoloToolkit-Examples/SharingWithUNET/Scripts/PlayerController.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ private void Start()
7878
transform.SetParent(sharedWorldAnchorTransform);
7979
}
8080

81+
private void OnDestroy()
82+
{
83+
if (isLocalPlayer)
84+
{
85+
InputManager.Instance.RemoveGlobalListener(gameObject);
86+
}
87+
}
88+
8189
private void Update()
8290
{
8391
// If we aren't the local player, we just need to make sure that the position of this object is set properly

Assets/HoloToolkit-Examples/SpatialUnderstanding/SpatialUnderstanding-FeatureOverview/Scripts/AppState.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ private void Start()
198198
InputManager.Instance.AddGlobalListener(gameObject);
199199
}
200200

201+
protected override void OnDestroy()
202+
{
203+
InputManager.Instance.RemoveGlobalListener(gameObject);
204+
}
205+
201206
private void Update_DebugDisplay(float deltaTime)
202207
{
203208
// Basic checks

Assets/HoloToolkit/Input/Scripts/SetGlobalListener.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,10 @@ private void Start()
1414
{
1515
InputManager.Instance.AddGlobalListener(gameObject);
1616
}
17+
18+
private void OnDestroy()
19+
{
20+
InputManager.Instance.RemoveGlobalListener(gameObject);
21+
}
1722
}
1823
}

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,23 @@ private void OnGUI()
9999
return;
100100
}
101101

102-
this.currentFrame = EditorGUILayout.IntSlider(this.currentFrame, 0, this.eventTimeline.Count - 1);
103-
scrollOffset = EditorGUILayout.BeginScrollView(scrollOffset);
104-
105-
if (this.eventTimeline.Count > this.currentFrame)
102+
//Fix null reference exception when launching with profiler is open
103+
if(eventTimeline!=null)
106104
{
107-
for (int i = 0; i < this.eventTimeline[this.currentFrame].Length; i++)
105+
this.currentFrame = EditorGUILayout.IntSlider(this.currentFrame, 0, this.eventTimeline.Count - 1);
106+
scrollOffset = EditorGUILayout.BeginScrollView(scrollOffset);
107+
108+
if (this.eventTimeline.Count > this.currentFrame)
108109
{
109-
DrawEventButton(this.eventTimeline[this.currentFrame][i], i);
110+
for (int i = 0; i < this.eventTimeline[this.currentFrame].Length; i++)
111+
{
112+
DrawEventButton(this.eventTimeline[this.currentFrame][i], i);
113+
}
110114
}
111-
}
112115

113-
EditorGUILayout.EndScrollView();
116+
EditorGUILayout.EndScrollView();
117+
}
118+
114119
}
115120

116121
private void DrawEventButton(ProfilerEvent currentEvent, int id)

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

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ public static UAudioManager Instance
5353
base.Awake();
5454

5555
CreateEventsDictionary();
56-
57-
if (events.Length > 0)
58-
{
59-
string key = events[0].name;
60-
PlayEvent(key);
61-
StopEvent(key);
62-
}
6356
}
6457

6558
/// <summary>
@@ -135,14 +128,15 @@ private void PlayEvent(string eventName,
135128
emitter = ApplyAudioEmitterTransform(emitter);
136129
if (emitter == null)
137130
{
138-
return;
131+
//if emitter is null, use the uaudiomanager gameobject(2dsound)
132+
emitter = gameObject;
139133
}
140134

141135
AudioEvent currentEvent;
142136

143137
if (!eventsDictionary.TryGetValue(eventName, out currentEvent))
144138
{
145-
Debug.LogErrorFormat(this, "Could not find event \"{0}\"", eventName);
139+
Debug.LogFormat( "Could not find event \"{0}\"", eventName);
146140
return;
147141
}
148142

@@ -196,80 +190,85 @@ private void PlayEvent(AudioEvent audioEvent,
196190
}
197191

198192
/// <summary>
199-
/// Stops all events with the name matching eventName.
193+
/// Stop event by gameObject.
200194
/// </summary>
201-
/// <param name="eventName">The name associated with the AudioEvents.</param>
202-
public void StopAllEvents(string eventName)
195+
/// <param name="eventName"></param>
196+
/// <param name="gameObjectToStop"></param>
197+
/// <param name="fadeOutTime"></param>
198+
public void StopEventsOnGameObject(string eventName, GameObject gameObjectToStop, float fadeOutTime = 0f)
203199
{
204200
for (int i = activeEvents.Count - 1; i >= 0; i--)
205201
{
206-
if (activeEvents[i].audioEvent.name == eventName)
202+
ActiveEvent activeEvent = activeEvents[i];
203+
204+
if (activeEvent.AudioEmitter == gameObjectToStop)
207205
{
208-
StopEvent(activeEvents[i]);
206+
StopEvent(activeEvent.audioEvent.name, gameObjectToStop, fadeOutTime);
209207
}
210208
}
211209
}
212210

211+
213212
/// <summary>
214-
/// Stops an AudioEvent.
213+
/// Stops all events by name.
215214
/// </summary>
216215
/// <param name="eventName">The name associated with the AudioEvent.</param>
217-
public void StopEvent(string eventName)
216+
/// <param name="fadeOutTime">The amount of time in seconds to completely fade out the sound.</param>
217+
public void StopAllEvents(string eventName, GameObject emitter = null, float fadeOutTime = 0f)
218218
{
219-
//if there's a default fade out time specified in the event, use it
219+
220220
for (int i = activeEvents.Count - 1; i >= 0; i--)
221221
{
222-
if (activeEvents[i].audioEvent.name == eventName)
222+
ActiveEvent activeEvent = activeEvents[i];
223+
224+
if (activeEvent.audioEvent.name == eventName)
223225
{
224-
StopEvent(eventName, activeEvents[i].audioEvent.fadeOutTime);
226+
if (fadeOutTime > 0)
227+
{
228+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, fadeOutTime));
229+
}
230+
else
231+
{
232+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, activeEvent.audioEvent.fadeOutTime));
233+
}
225234
}
226235
}
227236
}
228237

229238
/// <summary>
230-
/// Stops an AudioEvent.
239+
/// Stops all.
231240
/// </summary>
232-
/// <param name="eventName">The name associated with the AudioEvent.</param>
233-
/// <param name="emitter">The GameObject on which the AudioEvent will stopped.</param>
234-
public void StopEvent(string eventName, GameObject emitter)
241+
/// <param name="fadeOutTime">The amount of time in seconds to completely fade out the sound.</param>
242+
public void StopAll(GameObject emitter = null, float fadeOutTime = 0f)
235243
{
236-
emitter = ApplyAudioEmitterTransform(emitter);
237-
if (emitter == null)
244+
foreach (ActiveEvent activeEvent in activeEvents)
238245
{
239-
return;
240-
}
241-
242-
for (int i = activeEvents.Count - 1; i >= 0; i--)
243-
{
244-
if (activeEvents[i].audioEvent.name == eventName && activeEvents[i].AudioEmitter == emitter)
246+
if (fadeOutTime > 0)
245247
{
246-
StopEvent(activeEvents[i].audioEvent.name, emitter, activeEvents[i].audioEvent.fadeOutTime);
248+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, fadeOutTime));
249+
}
250+
else
251+
{
252+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, activeEvent.audioEvent.fadeOutTime));
247253
}
248254
}
249255
}
250256

251-
/// <summary>
252-
/// Stops an AudioEvent.
253-
/// </summary>
254-
/// <param name="eventName">The name associated with the AudioEvent.</param>
255-
/// <param name="fadeTime">The amount of time in seconds to completely fade out the sound.</param>
256-
public void StopEvent(string eventName, float fadeTime)
257-
{
258-
StopEvent(eventName, gameObject, fadeTime);
259-
}
257+
260258

261259
/// <summary>
262260
/// Stops an AudioEvent.
263261
/// </summary>
264262
/// <param name="eventName">The name associated with the AudioEvent.</param>
265263
/// <param name="emitter">The GameObject on which the AudioEvent will stopped.</param>
266264
/// <param name="fadeTime">The amount of time in seconds to completely fade out the sound.</param>
267-
public void StopEvent(string eventName, GameObject emitter, float fadeTime)
265+
public void StopEvent(string eventName, GameObject emitter = null, float fadeOutTime = 0f)
268266
{
269267
emitter = ApplyAudioEmitterTransform(emitter);
270268
if (emitter == null)
271269
{
272-
return;
270+
//if emitter is null, use the uaudiomanager gameobject(2dsound)
271+
emitter = gameObject;
273272
}
274273

275274
for (int i = activeEvents.Count - 1; i >= 0; i--)
@@ -278,7 +277,16 @@ public void StopEvent(string eventName, GameObject emitter, float fadeTime)
278277

279278
if (activeEvent.audioEvent.name == eventName && activeEvent.AudioEmitter == emitter)
280279
{
281-
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, fadeTime));
280+
//if there's no fade specified, use the fade stored in the event
281+
if (fadeOutTime > 0f)
282+
{
283+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, fadeOutTime));
284+
}
285+
else
286+
{
287+
StartCoroutine(StopEventWithFadeCoroutine(activeEvent, activeEvents[i].audioEvent.fadeOutTime));
288+
289+
}
282290
}
283291
}
284292
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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 System;
5+
using System.IO;
6+
using System.Text;
7+
using System.Text.RegularExpressions;
8+
using UnityEditor;
9+
using UnityEngine;
10+
11+
namespace HoloToolkit.Unity
12+
{
13+
/// <summary>
14+
/// Configuration options derived from here:
15+
/// https://developer.microsoft.com/en-us/windows/holographic/unity_development_overview#Configuring_a_Unity_project_for_HoloLens
16+
/// </summary>
17+
18+
19+
public class AutoConfigureMenu : MonoBehaviour
20+
{
21+
/// <summary>
22+
/// Displays a help page for the HoloToolkit.
23+
/// </summary>
24+
[MenuItem("HoloToolkit/Configure/Show Help", false, 3)]
25+
public static void ShowHelp()
26+
{
27+
Application.OpenURL("https://github.com/Microsoft/HoloToolkit-Unity/wiki");
28+
}
29+
30+
/// <summary>
31+
/// Applies recommended scene settings to the current scenes
32+
/// </summary>
33+
[MenuItem("HoloToolkit/Configure/Apply HoloLens Scene Settings", false, 1)]
34+
public static void ApplySceneSettings()
35+
{
36+
SceneSettingsWindow window = (SceneSettingsWindow)EditorWindow.GetWindow(typeof(SceneSettingsWindow), true, "Apply HoloLens Scene Settings");
37+
window.Show();
38+
}
39+
40+
/// <summary>
41+
/// Applies recommended project settings to the current project
42+
/// </summary>
43+
[MenuItem("HoloToolkit/Configure/Apply HoloLens Project Settings", false, 1)]
44+
public static void ApplyProjectSettings()
45+
{
46+
ProjectSettingsWindow window = (ProjectSettingsWindow)EditorWindow.GetWindow(typeof(ProjectSettingsWindow), true, "Apply HoloLens Project Settings");
47+
window.Show();
48+
}
49+
50+
/// <summary>
51+
/// Applies recommended capability settings to the current project
52+
/// </summary>
53+
[MenuItem("HoloToolkit/Configure/Apply HoloLens Capability Settings", false, 2)]
54+
static void ApplyHoloLensCapabilitySettings()
55+
{
56+
CapabilitySettingsWindow window = (CapabilitySettingsWindow)EditorWindow.GetWindow(typeof(CapabilitySettingsWindow), true, "Apply HoloLens Capability Settings");
57+
window.Show();
58+
}
59+
}
60+
}

Assets/HoloToolkit/Utilities/Editor/ConfigureMenu.cs.meta renamed to Assets/HoloToolkit/Utilities/Editor/AutoConfigureMenu.cs.meta

File renamed without changes.

0 commit comments

Comments
 (0)