Skip to content

Commit a60f48f

Browse files
committed
Add active loader checking for OpenXR
1 parent f5c8863 commit a60f48f

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Assets/MRTK/Providers/OpenXR/MRTK.OpenXR.asmdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"Microsoft.MixedReality.OpenXR",
66
"Microsoft.MixedReality.Toolkit",
77
"Microsoft.MixedReality.Toolkit.Providers.XRSDK",
8+
"Unity.XR.Management",
89
"Unity.XR.OpenXR"
910
],
1011
"includePlatforms": [

Assets/MRTK/Providers/OpenXR/Scripts/OpenXRDeviceManager.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
using Unity.Profiling;
99
using UnityEngine.XR;
1010

11+
#if UNITY_OPENXR
12+
using UnityEngine.XR.OpenXR;
13+
#endif // UNITY_OPENXR
14+
1115
namespace Microsoft.MixedReality.Toolkit.XRSDK.OpenXR
1216
{
1317
[MixedRealityDataProvider(
@@ -29,6 +33,34 @@ public OpenXRDeviceManager(
2933
uint priority = DefaultPriority,
3034
BaseMixedRealityProfile profile = null) : base(inputSystem, name, priority, profile) { }
3135

36+
private bool? isActiveLoader = null;
37+
private bool IsActiveLoader
38+
{
39+
get
40+
{
41+
#if UNITY_OPENXR
42+
if (!isActiveLoader.HasValue)
43+
{
44+
isActiveLoader = IsLoaderActive<OpenXRLoader>();
45+
}
46+
#endif // UNITY_OPENXR
47+
48+
return isActiveLoader ?? false;
49+
}
50+
}
51+
52+
/// <inheritdoc />
53+
public override void Enable()
54+
{
55+
if (!IsActiveLoader)
56+
{
57+
IsEnabled = false;
58+
return;
59+
}
60+
61+
base.Enable();
62+
}
63+
3264
#region Controller Utilities
3365

3466
private static readonly ProfilerMarker GetOrAddControllerPerfMarker = new ProfilerMarker("[MRTK] OpenXRDeviceManager.GetOrAddController");

0 commit comments

Comments
 (0)