Skip to content

Commit f5c8863

Browse files
committed
Improve enabled state checking for XR SDK
1 parent 069f575 commit f5c8863

File tree

3 files changed

+20
-27
lines changed

3 files changed

+20
-27
lines changed

Assets/MRTK/Providers/Oculus/XRSDK/OculusXRSDKDeviceManager.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
using System;
88
using UnityEngine.XR;
99

10-
#if OCULUSINTEGRATION_PRESENT
11-
using System.Collections.Generic;
1210
#if OCULUS_ENABLED
1311
using Unity.XR.Oculus;
1412
#endif // OCULUS_ENABLED
13+
14+
#if OCULUSINTEGRATION_PRESENT
15+
using System.Collections.Generic;
1516
using UnityEngine;
1617
#endif // OCULUSINTEGRATION_PRESENT
1718

@@ -137,7 +138,6 @@ protected override SupportedControllerType GetCurrentControllerType(InputDevice
137138

138139
#endregion Controller Utilities
139140

140-
#if OCULUSINTEGRATION_PRESENT
141141
private bool? isActiveLoader = null;
142142
private bool IsActiveLoader
143143
{
@@ -159,16 +159,19 @@ public override void Enable()
159159
{
160160
if (!IsActiveLoader)
161161
{
162+
IsEnabled = false;
162163
return;
163164
}
164165

165166
base.Enable();
166167

168+
#if OCULUSINTEGRATION_PRESENT
167169
SetupInput();
168170
ConfigurePerformancePreferences();
171+
#endif // OCULUSINTEGRATION_PRESENT
169172
}
170173

171-
174+
#if OCULUSINTEGRATION_PRESENT
172175
/// <inheritdoc/>
173176
public override void Update()
174177
{
@@ -349,6 +352,6 @@ private void RemoveHandDevice(OculusHand handDevice)
349352
}
350353

351354
#endregion
352-
#endif
355+
#endif // OCULUSINTEGRATION_PRESENT
353356
}
354357
}

Assets/MRTK/Providers/WindowsMixedReality/XRSDK/WindowsMixedRealityDeviceManager.cs

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,30 @@ public WindowsMixedRealityDeviceManager(
5050
uint priority = DefaultPriority,
5151
BaseMixedRealityProfile profile = null) : base(inputSystem, name, priority, profile) { }
5252

53-
#if WMR_ENABLED
5453
private bool? isActiveLoader = null;
5554
private bool IsActiveLoader
5655
{
5756
get
5857
{
5958
if (!isActiveLoader.HasValue)
6059
{
61-
isActiveLoader = IsLoaderActive("WindowsMRLoader");
60+
isActiveLoader = IsLoaderActive("Windows MR Loader");
6261
}
6362

6463
return isActiveLoader ?? false;
6564
}
6665
}
67-
#endif // WMR_ENABLED
6866

6967
#region IMixedRealityDeviceManager Interface
7068

71-
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
72-
private IMixedRealityGazeProviderHeadOverride mixedRealityGazeProviderHeadOverride = null;
73-
7469
/// <inheritdoc />
7570
public override void Enable()
7671
{
77-
#if WMR_ENABLED
7872
if (!IsActiveLoader)
7973
{
74+
IsEnabled = false;
8075
return;
8176
}
82-
#endif // WMR_ENABLED
8377

8478
base.Enable();
8579

@@ -88,7 +82,9 @@ public override void Enable()
8882
WindowsMixedRealityUtilities.UtilitiesProvider = new XRSDKWindowsMixedRealityUtilitiesProvider();
8983
}
9084

85+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
9186
mixedRealityGazeProviderHeadOverride = Service?.GazeProvider as IMixedRealityGazeProviderHeadOverride;
87+
#endif // (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
9288

9389
#if HP_CONTROLLER_ENABLED
9490
// Listens to events to track the HP Motion Controller
@@ -99,6 +95,9 @@ public override void Enable()
9995
#endif // HP_CONTROLLER_ENABLED
10096
}
10197

98+
#if (UNITY_WSA && DOTNETWINRT_PRESENT) || WINDOWS_UWP
99+
private IMixedRealityGazeProviderHeadOverride mixedRealityGazeProviderHeadOverride = null;
100+
102101
/// <inheritdoc />
103102
public override void Update()
104103
{
@@ -186,13 +185,6 @@ public override bool CheckCapability(MixedRealityCapability capability)
186185

187186
protected override GenericXRSDKController GetOrAddController(InputDevice inputDevice)
188187
{
189-
#if WMR_ENABLED
190-
if (!IsActiveLoader)
191-
{
192-
return null;
193-
}
194-
#endif // WMR_ENABLED
195-
196188
using (GetOrAddControllerPerfMarker.Auto())
197189
{
198190
GenericXRSDKController detectedController = base.GetOrAddController(inputDevice);
@@ -265,13 +257,6 @@ private uint GetControllerId(InputDevice inputDevice)
265257
/// <inheritdoc />
266258
protected override Type GetControllerType(SupportedControllerType supportedControllerType)
267259
{
268-
#if WMR_ENABLED
269-
if (!IsActiveLoader)
270-
{
271-
return null;
272-
}
273-
#endif // WMR_ENABLED
274-
275260
switch (supportedControllerType)
276261
{
277262
case SupportedControllerType.WindowsMixedReality:

Assets/MRTK/Providers/XRSDK/XRSDKDeviceManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public override void Update()
7979
{
8080
using (UpdatePerfMarker.Auto())
8181
{
82+
if (!IsEnabled)
83+
{
84+
return;
85+
}
86+
8287
base.Update();
8388

8489
if (XRSubsystemHelpers.InputSubsystem == null || !XRSubsystemHelpers.InputSubsystem.running)

0 commit comments

Comments
 (0)