using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// The session-relative data associated with a participant. /// /// /// A participant is another device in a multi-user collaborative session. /// /// [StructLayout(LayoutKind.Sequential)] public struct XRParticipant : ITrackable, IEquatable { TrackableId m_TrackableId; Pose m_Pose; TrackingState m_TrackingState; IntPtr m_NativePtr; Guid m_SessionId; /// /// Constructs an . s are generated /// by . /// /// The associated with this participant. /// The Pose associated with this participant. /// The associated with this participant. /// A native pointer associated with this participant. /// The session from which this participant originated. public XRParticipant( TrackableId trackableId, Pose pose, TrackingState trackingState, IntPtr nativePtr, Guid sessionId) { m_TrackableId = trackableId; m_Pose = pose; m_TrackingState = trackingState; m_NativePtr = nativePtr; m_SessionId = sessionId; } /// /// An with default values. This is mostly zero-initialized, /// except for objects like Poses, which are initialized to Pose.identity. /// public static XRParticipant defaultParticipant => k_Default; /// /// The associated with this participant. /// public TrackableId trackableId => m_TrackableId; /// /// The Pose, in session space, associated with this participant. /// public Pose pose => m_Pose; /// /// The associated with this participant. /// public TrackingState trackingState => m_TrackingState; /// /// A native pointer associated with this participant. /// The data pointer to by this pointer is implementation defined. /// public IntPtr nativePtr => m_NativePtr; /// /// This participant's session identifier. /// public Guid sessionId => m_SessionId; static readonly XRParticipant k_Default = new XRParticipant { m_TrackableId = TrackableId.invalidId, m_Pose = Pose.identity, m_NativePtr = IntPtr.Zero }; /// /// Generates a hash suitable for use with containers like HashSet and Dictionary. /// /// A hash suitable for use with containers like HashSet and Dictionary. public override int GetHashCode() { unchecked { int hash = m_TrackableId.GetHashCode(); hash = hash * 486187739 + m_Pose.GetHashCode(); hash = hash * 486187739 + ((int)m_TrackingState).GetHashCode(); hash = hash * 486187739 + m_NativePtr.GetHashCode(); return hash; } } /// /// Tests for equality. /// /// The other to compare against. /// true if is equal to this . public bool Equals(XRParticipant other) { return m_TrackableId.Equals(other.m_TrackableId) && m_Pose.Equals(other.m_Pose) && (m_TrackingState == other.m_TrackingState) && (m_NativePtr == other.m_NativePtr); } /// /// Tests for equality. /// /// The object to compare against. /// true if is of type and /// also returns true. public override bool Equals(object obj) => (obj is XRParticipant) && Equals((XRParticipant)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 . public static bool operator ==(XRParticipant lhs, XRParticipant 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 . public static bool operator !=(XRParticipant lhs, XRParticipant rhs) => !lhs.Equals(rhs); } }