Skip to content

Commit 5457aec

Browse files
committed
Add base loader checkers
1 parent 54f2c58 commit 5457aec

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Assets/MRTK/Providers/XRSDK/MRTK.XRSDK.asmdef

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "Microsoft.MixedReality.Toolkit.Providers.XRSDK",
33
"references": [
44
"Microsoft.MixedReality.Toolkit",
5+
"Unity.XR.Management",
56
"UnityEngine.SpatialTracking"
67
],
78
"includePlatforms": [],
@@ -18,6 +19,11 @@
1819
"name": "com.unity.xr.legacyinputhelpers",
1920
"expression": "",
2021
"define": "SPATIALTRACKING_ENABLED"
22+
},
23+
{
24+
"name": "com.unity.xr.management",
25+
"expression": "",
26+
"define": "XR_MANAGEMENT_ENABLED"
2127
}
2228
],
2329
"noEngineReferences": false

Assets/MRTK/Providers/XRSDK/XRSDKDeviceManager.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
using UnityEngine;
1010
using UnityEngine.XR;
1111

12+
#if XR_MANAGEMENT_ENABLED
13+
using UnityEngine.XR.Management;
14+
#endif // XR_MANAGEMENT_ENABLED
15+
1216
namespace Microsoft.MixedReality.Toolkit.XRSDK.Input
1317
{
1418
/// <summary>
@@ -52,6 +56,22 @@ public virtual bool CheckCapability(MixedRealityCapability capability)
5256
InputDeviceCharacteristics.HandTracking
5357
};
5458

59+
#if XR_MANAGEMENT_ENABLED
60+
/// <summary>
61+
/// Checks if the active loader has a specific name. Used in cases where the loader class is internal, like WindowsMRLoader.
62+
/// </summary>
63+
/// <param name="loaderName">The string name to compare against the active loader.</param>
64+
/// <returns>True if the active loader has the same name as the parameter.</returns>
65+
protected virtual bool IsLoaderActive(string loaderName) => XRGeneralSettings.Instance.Manager.activeLoader.name == loaderName;
66+
67+
/// <summary>
68+
/// Checks if the active loader is of a specific type. Used in cases where the loader class is accessible, like OculusLoader.
69+
/// </summary>
70+
/// <typeparam name="T">The loader class type to check against the active loader.</typeparam>
71+
/// <returns>True if the active loader is of the specified type.</returns>
72+
protected virtual bool IsLoaderActive<T>() where T : XRLoader => XRGeneralSettings.Instance.Manager.activeLoader is T;
73+
#endif // XR_MANAGEMENT_ENABLED
74+
5575
private static readonly ProfilerMarker UpdatePerfMarker = new ProfilerMarker("[MRTK] XRSDKDeviceManager.Update");
5676

5777
/// <inheritdoc/>

0 commit comments

Comments
 (0)