using System; using Unity.Collections; using UnityEngine.SubsystemsImplementation; namespace UnityEngine.XR.ARSubsystems { /// /// Base class for a reference point subsystem. /// /// /// A reference point is a pose in the physical environment that is tracked by an XR device. /// As the device refines its understanding of the environment, reference points will be /// updated, allowing you to keep virtual content connected to a real-world position and orientation. /// This abstract class should be implemented by an XR provider and instantiated using the SubsystemManager /// to enumerate the available s. /// [Obsolete("XRReferencePointSubsystem has been deprecated. Use XRAnchorSubsystem instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRAnchorSubsystem", false)] public class XRReferencePointSubsystem : TrackingSubsystem { /// /// Get the changes to reference points (added, updated, and removed) since the last call /// to . /// /// An allocator to use for the NativeArrays in . /// Changes since the last call to . public override TrackableChanges GetChanges(Allocator allocator) { if (!running) throw new InvalidOperationException("Can't call \"GetChanges\" without \"Start\"ing the reference-point subsystem!"); var changes = provider.GetChanges(XRReferencePoint.defaultValue, allocator); #if DEVELOPMENT_BUILD || UNITY_EDITOR m_ValidationUtility.ValidateAndDisposeIfThrown(changes); #endif return changes; } /// /// Attempts to create a new reference point with the provide . /// /// The pose, in session space, of the new reference point. /// The new reference point. Only valid if this method returns true. /// true if the new reference point was added, otherwise false. [Obsolete("XRReferencePointSubsystem.TryAddReferencePoint() has been deprecated. Use XRAnchorSubsystem.TryAddAnchor() instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRAnchorSubsystem.TryAddAnchor(Pose, XRAnchor)", true)] public bool TryAddReferencePoint(Pose pose, out XRReferencePoint referencePoint) { return provider.TryAddReferencePoint(pose, out referencePoint); } /// /// Attempts to create a new reference attached to the trackable with id . /// The behavior of the reference point depends on the type of trackable to which this reference point is attached. /// /// The id of the trackable to which to attach. /// The pose, in session space, of the reference point to create. /// The new reference point. Only valid if this method returns true. /// true if the new reference point was added, otherwise false. [Obsolete("XRReferencePointSubsystem.TryAttachReferencePoint() has been deprecated. Use XRAnchorSubsystem.TryAttachAnchor() instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRAnchorSubsystem.TryAttachAnchor(TrackableId, Pose, XRAnchor)", true)] public bool TryAttachReferencePoint(TrackableId trackableToAffix, Pose pose, out XRReferencePoint referencePoint) { return provider.TryAttachReferencePoint(trackableToAffix, pose, out referencePoint); } /// /// Attempts to remove an existing reference point with . /// /// The id of an existing reference point to remove. /// true if the reference point was removed, otherwise false. [Obsolete("XRReferencePointSubsystem.TryRemoveReferencePoint() has been deprecated. Use XRAnchorSubsystem.TryRemoveAnchor() instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRAnchorSubsystem.TryRemoveAnchor(*)", true)] public bool TryRemoveReferencePoint(TrackableId referencePointId) { return provider.TryRemoveReferencePoint(referencePointId); } /// /// An interface to be implemented by providers of this subsystem. /// public abstract class Provider : SubsystemProvider { /// /// Invoked when Start is called on the subsystem. This method is only called if the subsystem was not previously running. /// public override void Start() { } /// /// Invoked when Stop is called on the subsystem. This method is only called if the subsystem was previously running. /// public override void Stop() { } /// /// Called when Destroy is called on the subsystem. /// public override void Destroy() { } /// /// Invoked to get the changes to reference points (added, updated, and removed) since the last call to /// . /// /// The default reference point. This should be used to initialize the returned /// NativeArrays for backwards compatibility. /// See . /// /// An allocator to use for the NativeArrays in . /// Changes since the last call to . public abstract TrackableChanges GetChanges(XRReferencePoint defaultReferencePoint, Allocator allocator); /// /// Should create a new reference point with the provide . /// /// The pose, in session space, of the new reference point. /// The new reference point. Must be valid only if this method returns true. /// Should return true if the new reference point was added, otherwise false. public virtual bool TryAddReferencePoint(Pose pose, out XRReferencePoint referencePoint) { referencePoint = default(XRReferencePoint); return false; } /// /// Should create a new reference attached to the trackable with id . /// The behavior of the reference point depends on the type of trackable to which this reference point is attached and /// can be implemenation-defined. /// /// The id of the trackable to which to attach. /// The pose, in session space, of the reference point to create. /// The new reference point. Must be valid only if this method returns true. /// true if the new reference point was added, otherwise false. public virtual bool TryAttachReferencePoint( TrackableId trackableToAffix, Pose pose, out XRReferencePoint referencePoint) { referencePoint = default(XRReferencePoint); return false; } /// /// Should remove an existing reference point with . /// /// The id of an existing reference point to remove. /// Should return true if the reference point was removed, otherwise false. If the reference /// point does not exist, return false. public virtual bool TryRemoveReferencePoint(TrackableId referencePointId) => false; } #if DEVELOPMENT_BUILD || UNITY_EDITOR ValidationUtility m_ValidationUtility = new ValidationUtility(); #endif } }