WuhuIslandTesting/Library/PackageCache/com.unity.xr.mock-hmd@1.3.0-preview.1/Runtime/MockHMDLoader.cs
2025-01-07 02:06:59 +01:00

54 lines
1.7 KiB
C#

using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine.Experimental.XR;
using UnityEngine.XR;
using UnityEngine.XR.Management;
namespace Unity.XR.MockHMD
{
/// <summary>
/// Loader for Mock HMD.
/// </summary>
public class MockHMDLoader : XRLoaderHelper
{
private static List<XRDisplaySubsystemDescriptor> s_DisplaySubsystemDescriptors =
new List<XRDisplaySubsystemDescriptor>();
private static List<XRInputSubsystemDescriptor> s_InputSubsystemDescriptors =
new List<XRInputSubsystemDescriptor>();
public override bool Initialize()
{
CreateSubsystem<XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(s_DisplaySubsystemDescriptors, "MockHMD Display");
CreateSubsystem<XRInputSubsystemDescriptor, XRInputSubsystem>(s_InputSubsystemDescriptors, "MockHMD Head Tracking");
var buildSettings = MockHMDBuildSettings.Instance;
if (buildSettings != null)
{
MockHMD.SetRenderMode(buildSettings.renderMode);
}
return true;
}
public override bool Start()
{
StartSubsystem<XRDisplaySubsystem>();
StartSubsystem<XRInputSubsystem>();
return true;
}
public override bool Stop()
{
StopSubsystem<XRInputSubsystem>();
StopSubsystem<XRDisplaySubsystem>();
return true;
}
public override bool Deinitialize()
{
DestroySubsystem<XRInputSubsystem>();
DestroySubsystem<XRDisplaySubsystem>();
return true;
}
}
}