Skip to content

Commit c3cf9c2

Browse files
Merge pull request #1034 from StephenHodgson/MRTK-Dev2017.2-Updates
More WSA wrapping
2 parents 8b5dd43 + 6ccd172 commit c3cf9c2

File tree

9 files changed

+47
-45
lines changed

9 files changed

+47
-45
lines changed

Assets/HoloToolkit-Examples/SpatialMappingComponent/DropCube.cs

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

7-
#if UNITY_EDITOR || UNITY_WSA
7+
#if UNITY_WSA
88
using UnityEngine.XR.WSA.Input;
99
#endif
1010

@@ -15,7 +15,7 @@ namespace HoloToolkit.Examples.SpatialMappingComponent
1515
/// </summary>
1616
public class DropCube : MonoBehaviour
1717
{
18-
#if UNITY_EDITOR || UNITY_WSA
18+
#if UNITY_WSA
1919
private GestureRecognizer recognizer;
2020

2121
private void Start()

Assets/HoloToolkit/SharingWithUNET/UI/Scripts/StartSessionButton.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,11 @@ public class StartSessionButton : MonoBehaviour, IInputClickHandler
1919
void Start()
2020
{
2121
networkDiscovery = NetworkDiscoveryWithAnchors.Instance;
22-
#if !UNITY_EDITOR
23-
if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
22+
if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque && !Application.isEditor)
2423
{
2524
Debug.Log("Only hololens can host for now");
2625
Destroy(this.gameObject);
2726
}
28-
#endif
2927
}
3028

3129
/// <summary>
@@ -39,12 +37,13 @@ public void OnInputClicked(InputClickedEventData eventData)
3937
// Only let hololens host
4038
// We are also allowing the editor to host for testing purposes, but shared anchors
4139
// will currently not work in this mode.
42-
#if !UNITY_EDITOR
43-
if (!UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque)
44-
#else
45-
Debug.Log("Unity editor can host, but World Anchors will not be shared");
46-
#endif
40+
if (!UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque || Application.isEditor)
4741
{
42+
if (Application.isEditor)
43+
{
44+
Debug.Log("Unity editor can host, but World Anchors will not be shared");
45+
}
46+
4847
networkDiscovery.StartHosting("DefaultName");
4948
eventData.Use();
5049
}

Assets/HoloToolkit/SpatialMapping/Scripts/ObjectSurfaceObserver.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ public class ObjectSurfaceObserver : SpatialMappingSource
1313
[Tooltip("If greater than or equal to zero, surface objects will claim to be updated at this period. This is useful when working with libraries that respond to updates (such as the SpatialUnderstanding library). If negative, surfaces will not claim to be updated.")]
1414
public float SimulatedUpdatePeriodInSeconds = -1;
1515

16-
// Use this for initialization.
1716
private void Start()
1817
{
19-
#if UNITY_EDITOR
20-
if (!UnityEngine.XR.XRDevice.isPresent)
18+
if (!UnityEngine.XR.XRDevice.isPresent && Application.isEditor)
2119
{
2220
// When in the Unity editor and not remoting, try loading saved meshes from a model.
2321
Load(RoomModel);
@@ -27,7 +25,6 @@ private void Start()
2725
SpatialMappingManager.Instance.SetSpatialMappingSource(this);
2826
}
2927
}
30-
#endif
3128
}
3229

3330
/// <summary>

Assets/HoloToolkit/SpatialMapping/Scripts/SpatialMappingObserver.cs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System.Collections.Generic;
66
using UnityEngine;
77

8-
#if UNITY_EDITOR || UNITY_WSA
8+
#if UNITY_WSA
99
using UnityEngine.XR.WSA;
1010
#endif
1111

@@ -68,7 +68,8 @@ public class SpatialMappingObserver : SpatialMappingSource
6868
/// <summary>
6969
/// Indicates the current type of the observed volume
7070
/// </summary>
71-
[SerializeField][Tooltip("The shape of the observation volume.")]
71+
[SerializeField]
72+
[Tooltip("The shape of the observation volume.")]
7273
private ObserverVolumeTypes observerVolumeType = ObserverVolumeTypes.AxisAlignedBox;
7374
public ObserverVolumeTypes ObserverVolumeType
7475
{
@@ -78,15 +79,15 @@ public ObserverVolumeTypes ObserverVolumeType
7879
}
7980
set
8081
{
81-
if(observerVolumeType != value)
82+
if (observerVolumeType != value)
8283
{
8384
observerVolumeType = value;
8485
SwitchObservedVolume();
8586
}
8687
}
8788
}
8889

89-
#if UNITY_EDITOR || UNITY_WSA
90+
#if UNITY_WSA
9091
/// <summary>
9192
/// Our Surface Observer object for generating/updating Spatial Mapping data.
9293
/// </summary>
@@ -117,7 +118,8 @@ public ObserverVolumeTypes ObserverVolumeType
117118
/// </summary>
118119
private float updateTime;
119120

120-
[SerializeField][Tooltip("The extents of the observation volume.")]
121+
[SerializeField]
122+
[Tooltip("The extents of the observation volume.")]
121123
private Vector3 extents = Vector3.one * 10.0f;
122124
public Vector3 Extents
123125
{
@@ -127,7 +129,7 @@ public Vector3 Extents
127129
}
128130
set
129131
{
130-
if(extents != value)
132+
if (extents != value)
131133
{
132134
extents = value;
133135
SwitchObservedVolume();
@@ -138,7 +140,8 @@ public Vector3 Extents
138140
/// <summary>
139141
/// The origin of the observation volume.
140142
/// </summary>
141-
[SerializeField][Tooltip("The origin of the observation volume.")]
143+
[SerializeField]
144+
[Tooltip("The origin of the observation volume.")]
142145
private Vector3 origin = Vector3.zero;
143146
public Vector3 Origin
144147
{
@@ -148,7 +151,7 @@ public Vector3 Origin
148151
}
149152
set
150153
{
151-
if(origin != value)
154+
if (origin != value)
152155
{
153156
origin = value;
154157
SwitchObservedVolume();
@@ -159,7 +162,8 @@ public Vector3 Origin
159162
/// <summary>
160163
/// The direction of the observed volume, if an oriented box is choosen.
161164
/// </summary>
162-
[SerializeField][Tooltip("The direction of the observation volume.")]
165+
[SerializeField]
166+
[Tooltip("The direction of the observation volume.")]
163167
private Quaternion orientation = Quaternion.identity;
164168
public Quaternion Orientation
165169
{
@@ -169,11 +173,11 @@ public Quaternion Orientation
169173
}
170174
set
171175
{
172-
if(orientation != value)
176+
if (orientation != value)
173177
{
174178
orientation = value;
175179
// Only needs to be changed if the corresponding mode is active.
176-
if(ObserverVolumeType == ObserverVolumeTypes.OrientedBox)
180+
if (ObserverVolumeType == ObserverVolumeTypes.OrientedBox)
177181
{
178182
SwitchObservedVolume();
179183
}
@@ -188,7 +192,7 @@ protected override void Awake()
188192
ObserverState = ObserverStates.Stopped;
189193
}
190194

191-
#if UNITY_EDITOR || UNITY_WSA
195+
#if UNITY_WSA
192196
/// <summary>
193197
/// Called once per frame.
194198
/// </summary>
@@ -273,7 +277,7 @@ private void Update()
273277
/// </summary>
274278
public void StartObserving()
275279
{
276-
#if UNITY_EDITOR || UNITY_WSA
280+
#if UNITY_WSA
277281
if (observer == null)
278282
{
279283
observer = new SurfaceObserver();
@@ -297,7 +301,7 @@ public void StartObserving()
297301
/// <remarks>Sets the Surface Observer state to ObserverStates.Stopped.</remarks>
298302
public void StopObserving()
299303
{
300-
#if UNITY_EDITOR || UNITY_WSA
304+
#if UNITY_WSA
301305
if (ObserverState == ObserverStates.Running)
302306
{
303307
Debug.Log("Stopping the observer.");
@@ -314,7 +318,7 @@ public void StopObserving()
314318
/// </summary>
315319
public void CleanupObserver()
316320
{
317-
#if UNITY_EDITOR || UNITY_WSA
321+
#if UNITY_WSA
318322
StopObserving();
319323

320324
if (observer != null)
@@ -347,7 +351,7 @@ public bool SetObserverOrigin(Vector3 origin)
347351
{
348352
bool originUpdated = false;
349353

350-
#if UNITY_EDITOR || UNITY_WSA
354+
#if UNITY_WSA
351355
if (observer != null)
352356
{
353357
Origin = origin;
@@ -363,10 +367,10 @@ public bool SetObserverOrigin(Vector3 origin)
363367
/// </summary>
364368
private void SwitchObservedVolume()
365369
{
366-
#if UNITY_EDITOR || UNITY_WSA
370+
#if UNITY_WSA
367371
if (observer == null)
368372
{
369-
return;
373+
return;
370374
}
371375

372376
switch (observerVolumeType)
@@ -387,7 +391,7 @@ private void SwitchObservedVolume()
387391
#endif
388392
}
389393

390-
#if UNITY_EDITOR || UNITY_WSA
394+
#if UNITY_WSA
391395
/// <summary>
392396
/// Handles the SurfaceObserver's OnDataReady event.
393397
/// </summary>

Assets/HoloToolkit/SpatialUnderstanding/Scripts/SpatialUnderstandingCustomMesh.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using UnityEngine;
88
using HoloToolkit.Unity.SpatialMapping;
99

10-
#if UNITY_EDITOR || UNITY_WSA
10+
#if UNITY_WSA
1111
using UnityEngine.XR.WSA;
1212
#endif
1313

@@ -189,7 +189,7 @@ public void Commit()
189189
public void AddTriangle(Vector3 point1, Vector3 point2, Vector3 point3)
190190
{
191191
// Currently spatial understanding in the native layer voxellizes the space
192-
// into ~2000 voxels per cubic meter. Even in a degerate case we
192+
// into ~2000 voxels per cubic meter. Even in a degenerate case we
193193
// will use far fewer than 65000 vertices, this check should not fail
194194
// unless the spatial understanding native layer is updated to have more
195195
// voxels per cubic meter.
@@ -214,7 +214,7 @@ public void AddTriangle(Vector3 point1, Vector3 point2, Vector3 point3)
214214
private void Start()
215215
{
216216
spatialUnderstanding = SpatialUnderstanding.Instance;
217-
#if UNITY_EDITOR || UNITY_WSA
217+
#if UNITY_WSA
218218
if (gameObject.GetComponent<WorldAnchor>() == null)
219219
{
220220
gameObject.AddComponent<WorldAnchor>();

Assets/HoloToolkit/Utilities/Scripts/DisplayDependentObjectActivator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using UnityEngine;
55

6-
#if UNITY_EDITOR || UNITY_WSA
6+
#if UNITY_WSA
77
using UnityEngine.XR.WSA;
88
#endif
99

@@ -17,10 +17,12 @@ public class DisplayDependentObjectActivator : MonoBehaviour
1717

1818
protected void Awake()
1919
{
20+
#if UNITY_WSA
2021
if ((HolographicSettings.IsDisplayOpaque && !OpaqueDisplay) ||
2122
(!HolographicSettings.IsDisplayOpaque && !TransparentDisplay))
2223
{
2324
gameObject.SetActive(false);
2425
}
26+
#endif
2527
}
2628
}

Assets/HoloToolkit/Utilities/Scripts/Editor/ExternalProcess.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
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-
#if UNITY_EDITOR
54
using System;
65
using System.Diagnostics;
76
using System.IO;
@@ -293,4 +292,3 @@ protected virtual void Dispose(bool disposing)
293292
}
294293
}
295294
}
296-
#endif

Assets/HoloToolkit/Utilities/Scripts/FadeScript.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System;
22
using UnityEngine;
33

4-
#if UNITY_EDITOR || UNITY_WSA
4+
#if UNITY_WSA
55
using UnityEngine.XR.WSA;
66
#endif
77

@@ -36,12 +36,14 @@ public bool Busy
3636

3737
void Start()
3838
{
39+
#if UNITY_WSA
3940
if (!HolographicSettings.IsDisplayOpaque)
4041
{
4142
GetComponentInChildren<MeshRenderer>().enabled = false;
4243
Debug.Log("Removing unnecessary full screen effect from HoloLens");
4344
return;
4445
}
46+
#endif
4547

4648
currentState = FadeState.idle;
4749
fadeMaterial = GetComponentInChildren<MeshRenderer>().material;

Assets/HoloToolkit/Utilities/Scripts/StabilizationPlaneModifier.cs

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

7-
#if UNITY_EDITOR || UNITY_WSA
7+
#if UNITY_WSA
88
using UnityEngine.XR.WSA;
99
#endif
1010

@@ -186,7 +186,7 @@ private void ConfigureTransformOverridePlane(float deltaTime)
186186
velocity = UpdateVelocity(deltaTime);
187187
}
188188

189-
#if UNITY_EDITOR || UNITY_WSA
189+
#if UNITY_WSA
190190
// Place the plane at the desired depth in front of the user and billboard it to the gaze origin.
191191
HolographicSettings.SetFocusPointForFrame(planePosition, -GazeNormal, velocity);
192192
#endif
@@ -211,7 +211,7 @@ private void ConfigureGazeManagerPlane(float deltaTime)
211211
{
212212
focusPointDistance = DefaultPlaneDistance;
213213
}
214-
214+
215215
float lerpPower = focusPointDistance > currentPlaneDistance ? LerpStabilizationPlanePowerFarther
216216
: LerpStabilizationPlanePowerCloser;
217217

@@ -220,7 +220,7 @@ private void ConfigureGazeManagerPlane(float deltaTime)
220220

221221
planePosition = gazeOrigin + (gazeDirection * currentPlaneDistance);
222222

223-
#if UNITY_EDITOR || UNITY_WSA
223+
#if UNITY_WSA
224224
HolographicSettings.SetFocusPointForFrame(planePosition, -gazeDirection, Vector3.zero);
225225
#endif
226226
}
@@ -240,7 +240,7 @@ private void ConfigureFixedDistancePlane(float deltaTime)
240240
currentPlaneDistance = Mathf.Lerp(currentPlaneDistance, DefaultPlaneDistance, lerpPower * deltaTime);
241241

242242
planePosition = gazeOrigin + (gazeNormal * currentPlaneDistance);
243-
#if UNITY_EDITOR || UNITY_WSA
243+
#if UNITY_WSA
244244
HolographicSettings.SetFocusPointForFrame(planePosition, -gazeNormal, Vector3.zero);
245245
#endif
246246
}

0 commit comments

Comments
 (0)