using System; using Unity.Collections; using UnityEngine.SubsystemsImplementation; namespace UnityEngine.XR.ARSubsystems { /// /// An abstract class that provides a generic API for low-level depth detection features. /// /// /// This class can be used to access depth detection features in your app via accessing the generic API. /// It can also be extended to provide an implementation of a provider which provides the depth detection data /// to the higher level code. /// [Obsolete("XRDepthSubsystem has been deprecated. Use XRPointCloudSubsystem instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRPointCloudSubsystem", true)] public class XRDepthSubsystem : TrackingSubsystem { /// /// Get the changes to point clouds (added, updated, and removed) since the last call to . /// /// An Allocator to use when allocating the returned NativeArrays. /// /// describing the point clouds that have been added, updated, and removed /// since the last call to . The caller owns the memory allocated with Allocator. /// public override TrackableChanges GetChanges(Allocator allocator) { var changes = provider.GetChanges(XRPointCloud.defaultValue, allocator); #if DEVELOPMENT_BUILD || UNITY_EDITOR m_ValidationUtility.ValidateAndDisposeIfThrown(changes); #endif return changes; } /// /// Retrieve point cloud data (positions, confidence values, and identifiers) /// for the point cloud with the given . /// /// The point cloud for which to retrieve data. /// The allocator to use when creating the NativeArrays in the returned . Allocator.Temp is not supported; use Allocator.TempJob if you need temporary memory. /// /// A new with newly allocated NativeArrays using . /// The caller owns the memory and is responsible for calling on it. /// public XRPointCloudData GetPointCloudData( TrackableId trackableId, Allocator allocator) { if (allocator == Allocator.Temp) throw new InvalidOperationException("Allocator.Temp is not supported. Use Allocator.TempJob if you wish to use a temporary allocator."); if (allocator == Allocator.None) throw new InvalidOperationException("Allocator.None is not a valid allocator."); return provider.GetPointCloudData(trackableId, allocator); } /// /// The interface that each derived class must implement. /// public abstract class Provider : SubsystemProvider { /// /// Called when the subsystem starts. Will not be called again until . /// public override void Start() { } /// /// Called when the subsystem stops. Will not be called before . /// public override void Stop() { } /// /// Called when the subsystem is destroyed. will be called first if the subsystem is running. /// public override void Destroy() { } /// /// Get the changes to planes (added, updated, and removed) since the last call to /// . /// /// /// The default point cloud. This should be used to initialize the returned NativeArrays for backwards compatibility. /// See . /// /// An Allocator to use when allocating the returned NativeArrays. /// /// describing the reference points that have been added, updated, and removed /// since the last call to . The changes should be allocated using /// . /// public abstract TrackableChanges GetChanges(XRPointCloud defaultPointCloud, Allocator allocator); /// /// Generate point cloud data (positions, confidence values, and identifiers) /// for the point cloud with the given . /// /// The point cloud for which to retrieve data. /// The allocator to use when creating the NativeArrays in the returned . /// /// A new with newly allocated NativeArrays using . /// The caller owns the memory and is responsible for calling on it. /// public abstract XRPointCloudData GetPointCloudData(TrackableId trackableId, Allocator allocator); } #if DEVELOPMENT_BUILD || UNITY_EDITOR ValidationUtility m_ValidationUtility = new ValidationUtility(); #endif } }