using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// Contains all of the data provided for an individual environment probe in an AR session. /// [StructLayout (LayoutKind.Sequential)] public struct XREnvironmentProbe : IEquatable, ITrackable { /// /// Creates an populated with default values. /// public static XREnvironmentProbe defaultValue => s_Default; static readonly XREnvironmentProbe s_Default = new XREnvironmentProbe { trackableId = TrackableId.invalidId, pose = Pose.identity }; /// /// Constructs an . /// /// The associated with this tracked probe. /// The scale of the associated probe. /// The Pose associated with the probe. /// The size (rendering bounds) of the associated probe. /// The associated with the probe's cubemap. /// The of the probe. /// A native pointer associated with the probe's cubemap. public XREnvironmentProbe( TrackableId trackableId, Vector3 scale, Pose pose, Vector3 size, XRTextureDescriptor descriptor, TrackingState trackingState, IntPtr nativePtr) { m_TrackableId = trackableId; m_Scale = scale; m_Pose = pose; m_Size = size; m_TextureDescriptor = descriptor; m_TrackingState = trackingState; m_NativePtr = nativePtr; } /// /// Uniquely identifies each environment probe in an AR session. /// /// /// The unique trackable ID of the environment probe. /// public TrackableId trackableId { get => m_TrackableId; private set => m_TrackableId = value; } TrackableId m_TrackableId; /// /// Contains the scale of the environment probe in the AR session. /// /// /// The scale of the environment probe. /// public Vector3 scale { get => m_Scale; private set => m_Scale = value; } Vector3 m_Scale; /// /// Contains the pose (position and rotation) of the environment probe in the AR session. /// /// /// The pose (position and rotation) of the environment probe. /// public Pose pose { get => m_Pose; private set => m_Pose = value; } Pose m_Pose; /// /// Specifies the volume size around the environment probe's position. This is used for /// for parallax correction when projecting the environment texture. /// /// /// The bounding volume size of the environment probe. /// /// /// Note that size can be infinite. This is valid. /// public Vector3 size { get => m_Size; private set => m_Size = value; } Vector3 m_Size; /// /// Contains the texture descriptor captured from the device. /// /// /// The texture descriptor of the environment probe. /// /// /// The environmentTextureData value can be invalid, which indicates that the device has not captured an /// environment texture for this probe yet. Newly created environment probes have no environment texture. The /// property should be used to determine whether the texture data /// is valid. /// public XRTextureDescriptor textureDescriptor { get => m_TextureDescriptor; private set => m_TextureDescriptor = value; } XRTextureDescriptor m_TextureDescriptor; /// /// The associated with this environment probe. /// public TrackingState trackingState { get => m_TrackingState; private set => m_TrackingState = value; } TrackingState m_TrackingState; /// /// A native pointer associated with this environment probe. /// The data pointed to by this pointer is implementation-defined. Its lifetime /// is also implementation-defined, but will be valid at least until the next /// call to . /// public IntPtr nativePtr { get => m_NativePtr; private set => m_NativePtr = value; } IntPtr m_NativePtr; /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(XREnvironmentProbe other) { // Environment probes are equivalent if the trackable IDs match. return m_TrackableId.Equals(other.m_TrackableId); } /// /// Tests for equality. /// /// The `object` to compare against. /// `True` if is of type and /// also returns `true`; otherwise `false`. public override bool Equals(System.Object obj) => (obj is XREnvironmentProbe) && Equals((XREnvironmentProbe)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 ==(XREnvironmentProbe lhs, XREnvironmentProbe 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 !=(XREnvironmentProbe lhs, XREnvironmentProbe rhs) => !(lhs == rhs); /// /// 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() => m_TrackableId.GetHashCode(); /// /// Generates a string representation of this . /// /// A string representation of this . public override string ToString() => ToString("0.000"); /// /// Generates a string representation of this . Floating point /// values use to generate their string representations. /// /// The format specifier used for floating point fields. /// A string representation of this . public string ToString(string floatingPointformat) { return string.Format("{0} scale:{1} pose:{2} size:{3} environmentTextureData:{4} trackingState:{5} nativePtr:{6}", m_TrackableId.ToString(), m_Scale.ToString(floatingPointformat), m_Pose.ToString(floatingPointformat), m_Size.ToString(floatingPointformat), m_TextureDescriptor.ToString(), m_TrackingState.ToString(), m_NativePtr.ToString()); } } }