using System; using System.Collections.Generic; using System.Runtime.InteropServices; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using Unity.Jobs; using UnityEngine.Scripting; using UnityEngine.XR.ARSubsystems; using UnityEngine.XR.MagicLeap.Native; namespace UnityEngine.XR.MagicLeap { /// /// Subsystem for Image Tracking /// TODO: Implement when Image Tracking is available from the platform /// [Preserve] public sealed class ImageTrackingSubsystem : XRImageTrackingSubsystem { #if !UNITY_2020_2_OR_NEWER /// /// Create the generic XR Provider object from the magic leap Provider /// /// A Provider protected override Provider CreateProvider() => new MagicLeapProvider(); #endif class MagicLeapProvider : Provider { internal static bool IsSubsystemStateValid() { // TODO: Implement when Image Tracking is available from the platform return false; } /// /// Allows the user to re-request privileges /// /// /// true if the Color Camera privileges were granted and false otherwise. /// public bool RequestPermissionIfNecessary() { // TODO: Implement when Image Tracking is available from the platform return false; } public MagicLeapProvider() { // TODO: Implement when Image Tracking is available from the platform } #if UNITY_2020_2_OR_NEWER public override void Start() { } public override void Stop() { } #endif /// /// Destroy the image tracking subsystem. /// public override void Destroy() { // TODO: Implement when Image Tracking is available from the platform } /// /// The current RuntimeReferenceImageLibrary. If null then the subsystem will be set to "off". /// public override RuntimeReferenceImageLibrary imageLibrary { set { // TODO: Implement when Image Tracking is available from the platform } } public unsafe override TrackableChanges GetChanges(XRTrackedImage defaultTrackedImage, Allocator allocator) { // TODO: Implement when Image Tracking is available from the platform return default(TrackableChanges); } /// /// Stores the requested maximum number of concurrently tracked moving images. /// /// /// Magic Leap Image Tracking has the ability to set an enforcement policy on the maximum number of tracked /// moving images. If the policy has been explicitly set to false by using /// then /// this value will not be honored by the native provider until the policy is set to true. /// public override int requestedMaxNumberOfMovingImages { get => m_RequestedNumberOfMovingImages; set { m_RequestedNumberOfMovingImages = value; } } int m_RequestedNumberOfMovingImages = 25; /// /// Stores the current maximum number of moving images that can be tracked by the native platform. /// /// /// Magic Leap Image Tracking has the ability to set an enforcement policy on the maximum number of tracked /// moving images. If the policy has been explicitly set to false by using /// then /// this value will indicate the current number of explicitly declared moving images in the current library /// otherwise it will return the same value as . /// public override int currentMaxNumberOfMovingImages => m_RequestedNumberOfMovingImages; /// /// Creates a RuntimeReferenceImageLibrary from the passed in XRReferenceImageLibrary passed in. /// /// The XRReferenceImageLibrary that is used to create the RuntimeReferenceImageLibrary /// A new RuntimeReferenceImageLibrary created from the old public override RuntimeReferenceImageLibrary CreateRuntimeLibrary(XRReferenceImageLibrary serializedLibrary) { // TODO: Implement when Image Tracking is available from the platform return null; } } [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] static void RegisterDescriptor() { XRImageTrackingSubsystemDescriptor.Create(new XRImageTrackingSubsystemDescriptor.Cinfo { id = MagicLeapXrProvider.ImageTrackingSubsystemId, #if UNITY_2020_2_OR_NEWER providerType = typeof(MagicLeapProvider), subsystemTypeOverride = typeof(ImageTrackingSubsystem), #else subsystemImplementationType = typeof(ImageTrackingSubsystem), #endif // TODO: Update when Image Tracking is available from the platform supportsMovingImages = false, supportsMutableLibrary = false }); } } }