@@ -13,27 +13,40 @@ public static class LoaderHelpers
1313 /// Checks if the active loader has a specific name. Used in cases where the loader class is internal, like WindowsMRLoader.
1414 /// </summary>
1515 /// <param name="loaderName">The string name to compare against the active loader.</param>
16- /// <returns>True if the active loader has the same name as the parameter.</returns>
17- public static bool IsLoaderActive ( string loaderName ) =>
16+ /// <returns>True if the active loader has the same name as the parameter. Null if there isn't an active loader.</returns>
17+ public static bool ? IsLoaderActive ( string loaderName )
18+ {
1819#if XR_MANAGEMENT_ENABLED
19- XRGeneralSettings . Instance != null
20- && XRGeneralSettings . Instance . Manager != null
21- && XRGeneralSettings . Instance . Manager . activeLoader != null
22- && XRGeneralSettings . Instance . Manager . activeLoader . name == loaderName ;
20+ if ( XRGeneralSettings . Instance != null
21+ && XRGeneralSettings . Instance . Manager != null
22+ && XRGeneralSettings . Instance . Manager . activeLoader != null )
23+ {
24+ return XRGeneralSettings . Instance . Manager . activeLoader . name == loaderName ;
25+ }
26+
27+ return null ;
2328#else
24- false ;
29+ return false ;
2530#endif
31+ }
2632
2733#if XR_MANAGEMENT_ENABLED
2834 /// <summary>
2935 /// Checks if the active loader is of a specific type. Used in cases where the loader class is accessible, like OculusLoader.
3036 /// </summary>
3137 /// <typeparam name="T">The loader class type to check against the active loader.</typeparam>
32- /// <returns>True if the active loader is of the specified type.</returns>
33- public static bool IsLoaderActive < T > ( ) where T : XRLoader =>
34- XRGeneralSettings . Instance != null
35- && XRGeneralSettings . Instance . Manager != null
36- && XRGeneralSettings . Instance . Manager . activeLoader is T ;
38+ /// <returns>True if the active loader is of the specified type. Null if there isn't an active loader.</returns>
39+ public static bool ? IsLoaderActive < T > ( ) where T : XRLoader
40+ {
41+ if ( XRGeneralSettings . Instance != null
42+ && XRGeneralSettings . Instance . Manager != null
43+ && XRGeneralSettings . Instance . Manager . activeLoader != null )
44+ {
45+ return XRGeneralSettings . Instance . Manager . activeLoader is T ;
46+ }
47+
48+ return null ;
49+ }
3750#endif
3851 }
3952}
0 commit comments