using System; using Unity.Collections; using UnityEngine.SubsystemsImplementation; namespace UnityEngine.XR.ARSubsystems { /// /// This subsystem provides information regarding the detection of 3D bounding boxes in the physical environment. /// /// /// This is a base class with an abstract provider type to be implemented by provider plug-in packages. /// This class itself does not implement bounding box detection. /// public class XRBoundingBoxSubsystem : TrackingSubsystem { #if DEVELOPMENT_BUILD || UNITY_EDITOR ValidationUtility m_ValidationUtility = new(); #endif /// /// Do not invoke this constructor directly. /// /// /// If you are implementing your own custom subsystem [Lifecycle management](xref:xr-plug-in-management-provider#lifecycle-management), /// use the [SubsystemManager](xref:UnityEngine.SubsystemManager) /// to enumerate the available s, then call /// XRBoundingBoxSubsystemDescriptor.Register() on the desired descriptor. /// public XRBoundingBoxSubsystem() { } /// /// Gets a struct containing any changes to detected bounding boxes since the last /// time you called this method. You are responsible to the returned /// TrackableChanges instance. /// /// An Allocator to use for the returned NativeArrays. /// The . /// /// The struct returned by this method contains separate /// objects for the added, updated, and removed bounding boxes. These arrays are created /// using the type specified by . /// public override TrackableChanges GetChanges(Allocator allocator) { var changes = provider.GetChanges(default, allocator); #if DEVELOPMENT_BUILD || UNITY_EDITOR m_ValidationUtility.ValidateAndDisposeIfThrown(changes); #endif return changes; } /// /// The provider API for -derived classes to implement. /// public abstract class Provider : SubsystemProvider { /// /// Gets a struct containing any changes to detected bounding boxes since the last /// time you called this method. You are responsible to the returned /// TrackableChanges instance. /// /// The default bounding box. You should use this to initialize the returned /// instance by passing it to the constructor /// . /// /// An Allocator to use when allocating the returned NativeArrays. /// The changes to bounding boxes since the last call to this method. public abstract TrackableChanges GetChanges(XRBoundingBox defaultXRBoundingBox, Allocator allocator); } } }