using System;
using System.Collections.Generic;
using UnityEngine.XR.ARSubsystems;
using UnityEngine.XR.Management;
namespace UnityEngine.XR.ARKit
{
///
/// Manages the lifecycle of ARKit subsystems.
///
public class ARKitLoader : XRLoaderHelper
{
static List s_SessionSubsystemDescriptors = new List();
static List s_CameraSubsystemDescriptors = new List();
static List s_PointCloudSubsystemDescriptors = new List();
static List s_PlaneSubsystemDescriptors = new List();
static List s_AnchorSubsystemDescriptors = new List();
static List s_RaycastSubsystemDescriptors = new List();
static List s_HumanBodySubsystemDescriptors = new List();
static List s_EnvironmentProbeSubsystemDescriptors = new List();
static List s_InputSubsystemDescriptors = new List();
static List s_ImageTrackingSubsystemDescriptors = new List();
static List s_ObjectTrackingSubsystemDescriptors = new List();
static List s_FaceSubsystemDescriptors = new List();
static List s_OcclusionSubsystemDescriptors = new List();
static List s_ParticipantSubsystemDescriptors = new List();
static List s_MeshSubsystemDescriptors = new List();
static List s_BoundingBoxSubsystemDescriptors = new List();
///
/// The [XRSessionSubsystem](xref:UnityEngine.XR.ARSubsystems.XRSessionSubsystem) whose lifecycle is managed by this loader.
///
public XRSessionSubsystem sessionSubsystem => GetLoadedSubsystem();
///
/// The [XRCameraSubsystem](xref:UnityEngine.XR.ARSubsystems.XRCameraSubsystem) whose lifecycle is managed by this loader.
///
public XRCameraSubsystem cameraSubsystem => GetLoadedSubsystem();
///
/// The [XRDepthSubsystem](xref:UnityEngine.XR.ARSubsystems.XRDepthSubsystem) whose lifecycle is managed by this loader.
/// This field is obsolete. Use instead.
///
[Obsolete("Use pointCloudSubsystem instead. (2022-02-03)")]
public XRDepthSubsystem depthSubsystem => GetLoadedSubsystem();
///
/// The [XRPointCloudSubsystem](xref:UnityEngine.XR.ARSubsystems.XRPointCloudSubsystem) whose lifecycle is managed by this loader.
///
public XRPointCloudSubsystem pointCloudSubsystem => GetLoadedSubsystem();
///
/// The [XRPlaneSubsystem](xref:UnityEngine.XR.ARSubsystems.XRPlaneSubsystem) whose lifecycle is managed by this loader.
///
public XRPlaneSubsystem planeSubsystem => GetLoadedSubsystem();
///
/// The [XRAnchorSubsystem](xref:UnityEngine.XR.ARSubsystems.XRAnchorSubsystem) whose lifecycle is managed by this loader.
///
public XRAnchorSubsystem anchorSubsystem => GetLoadedSubsystem();
///
/// The [XRRaycastSubsystem](xref:UnityEngine.XR.ARSubsystems.XRRaycastSubsystem) whose lifecycle is managed by this loader.
///
public XRRaycastSubsystem raycastSubsystem => GetLoadedSubsystem();
///
/// The [XRHumanBodySubsystem](xref:UnityEngine.XR.ARSubsystems.XRHumanBodySubsystem) whose lifecycle is managed by this loader.
///
public XRHumanBodySubsystem humanBodySubsystem => GetLoadedSubsystem();
///
/// The [XREnvironmentProbeSubsystem](xref:UnityEngine.XR.ARSubsystems.XREnvironmentProbeSubsystem) whose lifecycle is managed by this loader.
///
public XREnvironmentProbeSubsystem environmentProbeSubsystem => GetLoadedSubsystem();
///
/// The [XRInputSubsystem](xref:UnityEngine.XR.XRInputSubsystem) whose lifecycle is managed by this loader.
///
public XRInputSubsystem inputSubsystem => GetLoadedSubsystem();
///
/// The [XRImageTrackingSubsystem](xref:UnityEngine.XR.ARSubsystems.XRImageTrackingSubsystem) whose lifecycle is managed by this loader.
///
public XRImageTrackingSubsystem imageTrackingSubsystem => GetLoadedSubsystem();
///
/// The [XRObjectTrackingSubsystem](xref:UnityEngine.XR.ARSubsystems.XRObjectTrackingSubsystem) whose lifecycle is managed by this loader.
///
public XRObjectTrackingSubsystem objectTrackingSubsystem => GetLoadedSubsystem();
///
/// The [XRFaceSubsystem](xref:UnityEngine.XR.ARSubsystems.XRFaceSubsystem) whose lifecycle is managed by this loader.
///
public XRFaceSubsystem faceSubsystem => GetLoadedSubsystem();
///
/// The [XROcclusionSubsystem](xref:UnityEngine.XR.ARSubsystems.XROcclusionSubsystem) whose lifecycle is managed by this loader.
///
public XROcclusionSubsystem occlusionSubsystem => GetLoadedSubsystem();
///
/// The [XRParticipantSubsystem](xref:UnityEngine.XR.ARSubsystems.XRParticipantSubsystem) whose lifecycle is managed by this loader.
///
public XRParticipantSubsystem participantSubsystem => GetLoadedSubsystem();
///
/// The [XRMeshSubsystem](xref:UnityEngine.XR.XRMeshSubsystem) whose lifecycle is
/// managed by this loader.
///
public XRMeshSubsystem meshSubsystem => GetLoadedSubsystem();
///
/// The [XRBoundingBoxSubsystem](xref:UnityEngine.XR.ARSubsystems.XRBoundingBoxSubsystem) whose lifecycle is managed by this loader.
///
public XRBoundingBoxSubsystem boundingBoxSubsystem => GetLoadedSubsystem();
///
/// Initializes the loader.
///
/// `True` if the session subsystem was successfully created, otherwise `false`.
public override bool Initialize()
{
#if UNITY_IOS && !UNITY_EDITOR
CreateSubsystem(s_SessionSubsystemDescriptors, "ARKit-Session");
CreateSubsystem(s_CameraSubsystemDescriptors, "ARKit-Camera");
CreateSubsystem(s_PointCloudSubsystemDescriptors, "ARKit-PointCloud");
CreateSubsystem(s_PlaneSubsystemDescriptors, "ARKit-Plane");
CreateSubsystem(s_AnchorSubsystemDescriptors, "ARKit-Anchor");
CreateSubsystem(s_RaycastSubsystemDescriptors, "ARKit-Raycast");
CreateSubsystem(s_HumanBodySubsystemDescriptors, "ARKit-HumanBody");
CreateSubsystem(s_EnvironmentProbeSubsystemDescriptors, "ARKit-EnvironmentProbe");
CreateSubsystem(s_InputSubsystemDescriptors, "ARKit-Input");
// Optional subsystems that might not have been registered, based on the iOS version.
CreateSubsystem(s_ImageTrackingSubsystemDescriptors, "ARKit-ImageTracking");
CreateSubsystem(s_ObjectTrackingSubsystemDescriptors, "ARKit-ObjectTracking");
CreateSubsystem(s_FaceSubsystemDescriptors, "ARKit-Face");
CreateSubsystem(s_OcclusionSubsystemDescriptors, "ARKit-Occlusion");
CreateSubsystem(s_ParticipantSubsystemDescriptors, "ARKit-Participant");
CreateSubsystem(s_MeshSubsystemDescriptors, "ARKit-Meshing");
CreateSubsystem(s_BoundingBoxSubsystemDescriptors, "ARKit-RoomPlan-BoundingBox");
if (sessionSubsystem == null)
{
Debug.LogError("Failed to load session subsystem.");
}
return sessionSubsystem != null;
#else
return false;
#endif
}
///
/// This method does nothing. Subsystems must be started individually.
///
/// Returns `true` on iOS. Returns `false` otherwise.
public override bool Start()
{
#if UNITY_IOS && !UNITY_EDITOR
return true;
#else
return false;
#endif
}
///
/// This method does nothing. Subsystems must be stopped individually.
///
/// Returns `true` on iOS. Returns `false` otherwise.
public override bool Stop()
{
#if UNITY_IOS && !UNITY_EDITOR
return true;
#else
return false;
#endif
}
///
/// Destroys each subsystem.
///
/// Always returns `true`.
public override bool Deinitialize()
{
#if UNITY_IOS && !UNITY_EDITOR
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
DestroySubsystem();
#endif
return true;
}
}
}