using System; using System.Runtime.InteropServices; using System.Text; namespace UnityEngine.XR.ARKit { /// /// Represents the minimum and maximum supported lens position. A lens position value doesn't correspond /// to an exact physical distance, nor does it represent a consistent focus distance from device to device. /// [StructLayout(LayoutKind.Sequential)] public struct ARKitFocusRange : IEquatable { float m_MinimumLensPosition; float m_MaximumLensPosition; /// /// Minimum supported lens position. This value represent the shortest distance at which the lens can focus. /// public float minimumLensPosition => m_MinimumLensPosition; /// /// Maximum supported lens position. This value represent the furthest distance at which the lens can focus. /// public float maximumLensPosition => m_MaximumLensPosition; /// /// Tests for equality. /// /// /// Two s are considered equal if their minimum lens position and maximum lens position are equal. /// /// The to compare against. /// if the lens position range is the same. Otherwise, . public bool Equals(ARKitFocusRange other) { return m_MinimumLensPosition.Equals(other.m_MinimumLensPosition) && m_MaximumLensPosition.Equals(other.m_MaximumLensPosition); } /// /// Tests for equality. /// /// An to compare against. /// if is an and is /// equal to this instance using . public override bool Equals(object obj) { return obj is ARKitFocusRange other && Equals(other); } /// /// Generates a hash code suitable for use with a `HashSet` or `Dictionary` /// /// A hash code for this . public override int GetHashCode() { int hashCode = 486187739; unchecked { hashCode = (hashCode * 486187739) + m_MinimumLensPosition.GetHashCode(); hashCode = (hashCode * 486187739) + m_MaximumLensPosition.GetHashCode(); } return hashCode; } /// /// Tests for equality. Same as . /// /// The to compare with . /// The to compare with . /// if is equal to using /// . Otherwise, . public static bool operator ==(ARKitFocusRange lhs, ARKitFocusRange rhs) => lhs.Equals(rhs); /// /// Tests for inequality. Same as the negation of . /// /// The to compare with . /// The to compare with . /// if is equal to using /// . Otherwise, . public static bool operator !=(ARKitFocusRange lhs, ARKitFocusRange rhs) => !lhs.Equals(rhs); /// /// Generates a string representation of this suitable for debugging purposes. /// /// A string representation of this . public override string ToString() { var sb = new StringBuilder(); sb.AppendLine("{"); sb.AppendLine($" MinimumLensPosition: {m_MinimumLensPosition:0.000}"); sb.AppendLine($" MaximumLensPosition: {m_MaximumLensPosition:0.000}"); sb.AppendLine("}"); return sb.ToString(); } } }