using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// Describes session relative data for a reference point. /// /// [StructLayout(LayoutKind.Sequential)] [Obsolete("XRReferencePoint has been deprecated. Use XRAnchor instead (UnityUpgradable) -> UnityEngine.XR.ARSubsystems.XRAnchor", true)] public struct XRReferencePoint : ITrackable, IEquatable { /// /// Gets a default-initialized . This can be /// different from the zero-initialized version (for example, the /// is Pose.identity instead of zero-initialized). /// public static XRReferencePoint defaultValue => s_Default; static readonly XRReferencePoint s_Default = new XRReferencePoint { m_Id = TrackableId.invalidId, m_Pose = Pose.identity, m_SessionId = Guid.Empty }; /// /// Constructs the session-relative data for a reference point. /// This is typically provided by an implementation of the /// and not invoked directly. /// /// The associated with this reference point. /// The Pose, in session space, of the reference point. /// The of the reference point. /// A native pointer associated with the reference point. The data pointed to by /// this pointer is implementation-specific. public XRReferencePoint( TrackableId trackableId, Pose pose, TrackingState trackingState, IntPtr nativePtr) { m_Id = trackableId; m_Pose = pose; m_TrackingState = trackingState; m_NativePtr = nativePtr; m_SessionId = Guid.Empty; } /// /// Constructs the session-relative data for a reference point. /// This is typically provided by an implementation of the /// and not invoked directly. /// /// The associated with this reference point. /// The Pose, in session space, of the reference point. /// The of the reference point. /// A native pointer associated with the reference point. The data pointed to by /// this pointer is implementation-specific. /// The session from which this reference point originated. public XRReferencePoint( TrackableId trackableId, Pose pose, TrackingState trackingState, IntPtr nativePtr, Guid sessionId) : this(trackableId, pose, trackingState, nativePtr) { m_SessionId = sessionId; } /// /// Get the associated with this reference point. /// public TrackableId trackableId => m_Id; /// /// Get the Pose, in session space, for this reference point. /// public Pose pose => m_Pose; /// /// Get the of this reference point. /// public TrackingState trackingState => m_TrackingState; /// /// A native pointer associated with the reference point. /// The data pointed to by this pointer is implementation-specific. /// public IntPtr nativePtr => m_NativePtr; /// /// The id of the session from which this reference point originated. /// public Guid sessionId => m_SessionId; /// /// Generates a hash suitable for use with containers like `HashSet` and `Dictionary`. /// /// A hash code generated from this object's fields. public override int GetHashCode() { unchecked { var hashCode = m_Id.GetHashCode(); hashCode = hashCode * 486187739 + m_Pose.GetHashCode(); hashCode = hashCode * 486187739 + m_TrackingState.GetHashCode(); hashCode = hashCode * 486187739 + m_NativePtr.GetHashCode(); hashCode = hashCode * 486187739 + m_SessionId.GetHashCode(); return hashCode; } } /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(XRReferencePoint other) { return m_Id.Equals(other.m_Id) && m_Pose.Equals(other.m_Pose) && m_TrackingState == other.m_TrackingState && m_NativePtr == other.m_NativePtr && m_SessionId.Equals(other.m_SessionId); } /// /// Tests for equality. /// /// The `object` to compare against. /// `True` if is of type and /// also returns `true`; otherwise `false`. public override bool Equals(object obj) => obj is XRReferencePoint && Equals((XRReferencePoint)obj); /// /// Tests for equality. Same as . /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// `True` if is equal to , otherwise `false`. public static bool operator==(XRReferencePoint lhs, XRReferencePoint rhs) => lhs.Equals(rhs); /// /// Tests for inequality. Same as `!`. /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// `True` if is not equal to , otherwise `false`. public static bool operator!=(XRReferencePoint lhs, XRReferencePoint rhs) => !lhs.Equals(rhs); TrackableId m_Id; Pose m_Pose; TrackingState m_TrackingState; IntPtr m_NativePtr; Guid m_SessionId; } }