Skip to content

Commit 6a32ab1

Browse files
Merge branch 'HTK-Master' into HTK-BuildFixes
2 parents f80ea0e + db6fe66 commit 6a32ab1

File tree

24 files changed

+352
-125
lines changed

24 files changed

+352
-125
lines changed

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/GestureInteractive.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
using UnityEngine;
55
using System.Collections;
6-
using UnityEngine.Events;
7-
using HoloToolkit.Unity;
8-
using UnityEngine.VR.WSA.Input;
9-
using UnityEngine.Windows.Speech;
106
using HoloToolkit.Unity.InputModule;
11-
using HoloToolkit.Examples.Prototyping;
7+
8+
#if UNITY_EDITOR || UNITY_WSA
9+
using UnityEngine.Windows.Speech;
10+
#endif
1211

1312
namespace HoloToolkit.Examples.InteractiveElements
1413
{
@@ -303,6 +302,7 @@ protected override void Update()
303302
}
304303
}
305304

305+
#if UNITY_EDITOR || UNITY_WSA
306306
/// <summary>
307307
/// From Interactive, but customized for triggering gestures from keywords
308308
/// Handle the manipulation in the GestureInteractiveControl
@@ -323,6 +323,7 @@ protected override void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEve
323323
}
324324
}
325325
}
326+
#endif
326327

327328
/// <summary>
328329
/// Clean up

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/Interactive.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using UnityEngine;
5-
using System.Collections;
65
using UnityEngine.Events;
7-
using HoloToolkit.Unity;
8-
using UnityEngine.Windows.Speech;
96
using System.Collections.Generic;
107
using HoloToolkit.Unity.InputModule;
118

9+
#if UNITY_EDITOR || UNITY_WSA
10+
using UnityEngine.Windows.Speech;
11+
#endif
12+
1213
namespace HoloToolkit.Examples.InteractiveElements
1314
{
1415
/// <summary>
@@ -87,7 +88,9 @@ public enum ButtonStateEnum { Default, Focus, Press, Selected, FocusSelected, Pr
8788
protected bool mCheckRollOff = false;
8889
protected bool mCheckHold = false;
8990

91+
#if UNITY_EDITOR || UNITY_WSA
9092
protected KeywordRecognizer mKeywordRecognizer;
93+
#endif
9194
protected Dictionary<string, int> mKeywordDictionary;
9295
protected string[] mKeywordArray;
9396

@@ -131,12 +134,14 @@ protected virtual void Start()
131134
}
132135
}
133136

137+
#if UNITY_EDITOR || UNITY_WSA
134138
if (!KeywordRequiresGaze)
135139
{
136140
mKeywordRecognizer = new KeywordRecognizer(mKeywordArray);
137141
mKeywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
138142
mKeywordRecognizer.Start();
139143
}
144+
#endif
140145

141146
}
142147

@@ -201,6 +206,7 @@ public virtual void OnFocusExit()
201206

202207
private void SetKeywordListener(bool listen)
203208
{
209+
#if UNITY_EDITOR || UNITY_WSA
204210
if (listen)
205211
{
206212
if (KeywordRequiresGaze && mKeywordArray != null)
@@ -233,6 +239,7 @@ private void SetKeywordListener(bool listen)
233239
}
234240
}
235241
}
242+
#endif
236243
}
237244

238245
/// <summary>
@@ -367,6 +374,7 @@ public void UnregisterWidget(InteractiveWidget widget)
367374
}
368375
}
369376

377+
#if UNITY_EDITOR || UNITY_WSA
370378
protected virtual void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
371379
{
372380

@@ -379,6 +387,7 @@ protected virtual void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEven
379387
}
380388
}
381389
}
390+
#endif
382391

383392
/// <summary>
384393
/// Check if any state changes have occured, from alternate input sources
@@ -501,10 +510,12 @@ protected virtual void OnDestroy()
501510

502511
protected virtual void OnEnable()
503512
{
513+
#if UNITY_EDITOR || UNITY_WSA
504514
if (mKeywordRecognizer != null && !KeywordRequiresGaze)
505515
{
506516
SetKeywordListener(true);
507517
}
518+
#endif
508519
}
509520

510521
protected virtual void OnDisable()

Assets/HoloToolkit-Examples/InteractiveElements/Scripts/InteractiveToggle.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

4-
using UnityEngine;
5-
using System.Collections;
64
using UnityEngine.Events;
7-
using UnityEngine.Windows.Speech;
85
using HoloToolkit.Unity.InputModule;
96

7+
#if UNITY_EDITOR || UNITY_WSA
8+
using UnityEngine.Windows.Speech;
9+
#endif
10+
1011
namespace HoloToolkit.Examples.InteractiveElements
1112
{
1213
/// <summary>
@@ -18,7 +19,7 @@ namespace HoloToolkit.Examples.InteractiveElements
1819
/// </summary>
1920
public class InteractiveToggle : Interactive
2021
{
21-
22+
2223
/// <summary>
2324
/// Sets the button to act like a navigation button or toggle type button
2425
/// </summary>
@@ -189,6 +190,7 @@ protected override void Update()
189190

190191
}
191192

193+
#if UNITY_EDITOR || UNITY_WSA
192194
protected override void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
193195
{
194196
base.KeywordRecognizer_OnPhraseRecognized(args);
@@ -205,5 +207,6 @@ protected override void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEve
205207
}
206208
}
207209
}
210+
#endif
208211
}
209212
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using UnityEngine;
55
using HoloToolkit.Unity;
66

7-
#if !UNITY_EDITOR
7+
#if !UNITY_EDITOR && UNITY_WSA
88
using Windows.Networking.Sockets;
99
using Windows.Storage.Streams;
1010
using Windows.Networking;
@@ -74,7 +74,7 @@ public void RequestAndGetData()
7474
}
7575

7676
// A lot of the work done in this class can only be done in UWP. The editor is not a UWP app.
77-
#if !UNITY_EDITOR
77+
#if !UNITY_EDITOR && UNITY_WSA
7878
/// <summary>
7979
/// Tracks the network connection to the remote machine we are sending meshes to.
8080
/// </summary>
@@ -206,7 +206,7 @@ private async void RcvNetworkConnectedHandler(IAsyncAction asyncInfo, AsyncStatu
206206
}
207207

208208
#else
209-
public void ConfigureAsServer()
209+
public void ConfigureAsServer()
210210
{
211211
Debug.Log("This script is not intended to be run from the Unity Editor");
212212
// In order to avoid compiler warnings in the Unity Editor we have to access a few of our fields.

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

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
using System.Collections.Generic;
66
using UnityEngine.Networking;
77
using HoloToolkit.Unity;
8+
using System;
9+
10+
#if UNITY_EDITOR || UNITY_WSA
811
using UnityEngine.VR.WSA.Sharing;
912
using UnityEngine.VR.WSA;
1013
using UnityEngine.VR.WSA.Persistence;
11-
using System;
14+
#endif
1215

1316
namespace HoloToolkit.Examples.SharingWithUNET
1417
{
@@ -152,32 +155,25 @@ private void Start()
152155
networkTransmitter.dataReadyEvent += NetworkTransmitter_dataReadyEvent;
153156
}
154157

155-
private void Update()
158+
/// <summary>
159+
/// Called when anchor data is ready.
160+
/// </summary>
161+
/// <param name="data">The data blob to import.</param>
162+
private void NetworkTransmitter_dataReadyEvent(byte[] data)
156163
{
157-
if (gotOne)
158-
{
159-
Debug.Log("importing");
160-
gotOne = false;
161-
ImportInProgress = true;
162-
WorldAnchorTransferBatch.ImportAsync(anchorData, ImportComplete);
163-
}
164-
165-
if (oldAnchorName != AnchorName && !createdAnchor)
166-
{
167-
Debug.LogFormat("New anchor name {0} {1}", oldAnchorName, AnchorName);
168-
oldAnchorName = AnchorName;
169-
if (!AttachToCachedAnchor(AnchorName))
170-
{
171-
WaitForAnchor();
172-
}
173-
}
164+
Debug.Log("Anchor data arrived.");
165+
anchorData = data;
166+
Debug.Log(data.Length);
167+
DownloadingAnchor = false;
168+
gotOne = true;
174169
}
175170

176171
/// <summary>
177172
/// If we are supposed to create the anchor for export, this is the function to call.
178173
/// </summary>
179174
public void CreateAnchor()
180175
{
176+
#if UNITY_EDITOR || UNITY_WSA
181177
objectToAnchor = SharedCollection.Instance.gameObject;
182178
WorldAnchorTransferBatch watb = new WorldAnchorTransferBatch();
183179
WorldAnchor worldAnchor = objectToAnchor.GetComponent<WorldAnchor>();
@@ -190,6 +186,7 @@ public void CreateAnchor()
190186
Debug.Log("exporting " + exportingAnchorName);
191187
watb.AddWorldAnchor(exportingAnchorName, worldAnchor);
192188
WorldAnchorTransferBatch.ExportAsync(watb, WriteBuffer, ExportComplete);
189+
#endif
193190
}
194191

195192
/// <summary>
@@ -207,6 +204,7 @@ public void WaitForAnchor()
207204
/// <returns>True if it attached, false if it could not attach</returns>
208205
private bool AttachToCachedAnchor(string AnchorName)
209206
{
207+
#if UNITY_EDITOR || UNITY_WSA
210208
WorldAnchorStore anchorStore = WorldAnchorManager.Instance.AnchorStore;
211209
Debug.Log("Looking for " + AnchorName);
212210
string[] ids = anchorStore.GetAllIds();
@@ -220,22 +218,40 @@ private bool AttachToCachedAnchor(string AnchorName)
220218
return true;
221219
}
222220
}
223-
221+
#endif
224222
// Didn't find the anchor.
225223
return false;
226224
}
227225

228226
/// <summary>
229-
/// Called when anchor data is ready.
227+
/// Called as anchor data becomes available to export
230228
/// </summary>
231-
/// <param name="data">The data blob to import.</param>
232-
private void NetworkTransmitter_dataReadyEvent(byte[] data)
229+
/// <param name="data">The next chunk of data.</param>
230+
private void WriteBuffer(byte[] data)
233231
{
234-
Debug.Log("Anchor data arrived.");
235-
anchorData = data;
236-
Debug.Log(data.Length);
237-
DownloadingAnchor = false;
238-
gotOne = true;
232+
exportingAnchorBytes.AddRange(data);
233+
}
234+
235+
#if UNITY_EDITOR || UNITY_WSA
236+
private void Update()
237+
{
238+
if (gotOne)
239+
{
240+
Debug.Log("importing");
241+
gotOne = false;
242+
ImportInProgress = true;
243+
WorldAnchorTransferBatch.ImportAsync(anchorData, ImportComplete);
244+
}
245+
246+
if (oldAnchorName != AnchorName && !createdAnchor)
247+
{
248+
Debug.LogFormat("New anchor name {0} {1}", oldAnchorName, AnchorName);
249+
oldAnchorName = AnchorName;
250+
if (!AttachToCachedAnchor(AnchorName))
251+
{
252+
WaitForAnchor();
253+
}
254+
}
239255
}
240256

241257
/// <summary>
@@ -271,15 +287,6 @@ private void ImportComplete(SerializationCompletionReason status, WorldAnchorTra
271287
}
272288
}
273289

274-
/// <summary>
275-
/// Called as anchor data becomes available to export
276-
/// </summary>
277-
/// <param name="data">The next chunk of data.</param>
278-
private void WriteBuffer(byte[] data)
279-
{
280-
exportingAnchorBytes.AddRange(data);
281-
}
282-
283290
/// <summary>
284291
/// Called when serializing an anchor is complete.
285292
/// </summary>
@@ -301,5 +308,6 @@ private void ExportComplete(SerializationCompletionReason status)
301308
CreateAnchor();
302309
}
303310
}
311+
#endif
304312
}
305313
}

Assets/HoloToolkit-Examples/SpatialMappingComponent/DropCube.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
// Licensed under the MIT License. See LICENSE in the project root for license information.
33

44
using UnityEngine;
5+
6+
#if UNITY_EDITOR || UNITY_WSA
57
using UnityEngine.VR.WSA.Input;
8+
#endif
69

710
namespace HoloToolkit.Examples.SpatialMappingComponent
811
{
@@ -11,6 +14,7 @@ namespace HoloToolkit.Examples.SpatialMappingComponent
1114
/// </summary>
1215
public class DropCube : MonoBehaviour
1316
{
17+
#if UNITY_EDITOR || UNITY_WSA
1418
GestureRecognizer recognizer;
1519

1620
private void Start()
@@ -33,5 +37,6 @@ private void Recognizer_TappedEvent(InteractionSourceKind source, int tapCount,
3337
cube.transform.position = Camera.main.transform.position + Camera.main.transform.forward; // Start to drop it in front of the camera
3438
cube.AddComponent<Rigidbody>(); // Apply physics
3539
}
40+
#endif
3641
}
3742
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
using System.Collections.Generic;
99
using System.Linq;
1010
using UnityEngine;
11+
12+
#if UNITY_EDITOR || UNITY_WSA
1113
using UnityEngine.Windows.Speech;
14+
#endif
1215

1316
namespace HoloToolkit.Examples.SpatialUnderstandingFeatureOverview
1417
{
@@ -192,6 +195,7 @@ public string DetailsText
192195
private string spaceQueryDescription;
193196
private string objectPlacementDescription;
194197
private uint trackedHandsCount = 0;
198+
#if UNITY_EDITOR || UNITY_WSA
195199
private KeywordRecognizer keywordRecognizer;
196200

197201
// Functions
@@ -214,6 +218,7 @@ private void Start()
214218
keywordRecognizer.OnPhraseRecognized += args => keywordsToActions[args.text].Invoke();
215219
keywordRecognizer.Start();
216220
}
221+
#endif
217222

218223
protected override void OnDestroy()
219224
{

0 commit comments

Comments
 (0)