// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#if XR_MANAGEMENT_ENABLED
using UnityEngine.XR.Management;
#endif
namespace Microsoft.MixedReality.Toolkit.XRSDK
{
public static class LoaderHelpers
{
///
/// Checks if the active loader has a specific name. Used in cases where the loader class is internal, like WindowsMRLoader.
///
/// The string name to compare against the active loader.
/// True if the active loader has the same name as the parameter. Null if there isn't an active loader.
public static bool? IsLoaderActive(string loaderName)
{
#if XR_MANAGEMENT_ENABLED
if (XRGeneralSettings.Instance != null
&& XRGeneralSettings.Instance.Manager != null
&& XRGeneralSettings.Instance.Manager.activeLoader != null)
{
return XRGeneralSettings.Instance.Manager.activeLoader.name == loaderName;
}
return null;
#else
return false;
#endif
}
#if XR_MANAGEMENT_ENABLED
///
/// Checks if the active loader is of a specific type. Used in cases where the loader class is accessible, like OculusLoader.
///
/// The loader class type to check against the active loader.
/// True if the active loader is of the specified type. Null if there isn't an active loader.
public static bool? IsLoaderActive() where T : XRLoader
{
if (XRGeneralSettings.Instance != null
&& XRGeneralSettings.Instance.Manager != null
&& XRGeneralSettings.Instance.Manager.activeLoader != null)
{
return XRGeneralSettings.Instance.Manager.activeLoader is T;
}
return null;
}
#endif
}
}