using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { /// /// Parameters of the Unity Camera that might be necessary or useful to the provider. /// [StructLayout(LayoutKind.Sequential)] public struct XRCameraParams : IEquatable { /// /// Distance from the camera to the near plane. /// /// Distance from the camera to the near plane. public float zNear { get => m_ZNear; set => m_ZNear = value; } float m_ZNear; /// /// Distance from the camera to the far plane. /// /// Distance from the camera to the far plane. public float zFar { get => m_ZFar; set => m_ZFar = value; } float m_ZFar; /// /// Width, in pixels, of the screen resolution. /// /// Width, in pixels, of the screen resolution. public float screenWidth { get => m_ScreenWidth; set => m_ScreenWidth = value; } float m_ScreenWidth; /// /// Height, in pixels, of the screen resolution. /// /// Height, in pixels, of the screen resolution. public float screenHeight { get => m_ScreenHeight; set => m_ScreenHeight = value; } float m_ScreenHeight; /// /// The orientation of the screen. /// /// The orientation of the screen. public ScreenOrientation screenOrientation { get => m_ScreenOrientation; set => m_ScreenOrientation = value; } ScreenOrientation m_ScreenOrientation; /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(XRCameraParams other) { return (m_ZNear.Equals(other.m_ZNear) && m_ZFar.Equals(other.m_ZFar) && m_ScreenWidth.Equals(other.m_ScreenWidth) && m_ScreenHeight.Equals(other.m_ScreenHeight) && (m_ScreenOrientation == other.m_ScreenOrientation)); } /// /// 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) { return ((obj is XRCameraParams) && Equals((XRCameraParams)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 ==(XRCameraParams lhs, XRCameraParams 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 !=(XRCameraParams lhs, XRCameraParams rhs) => !lhs.Equals(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() { int hashCode = 486187739; unchecked { hashCode = (hashCode * 486187739) + m_ZNear.GetHashCode(); hashCode = (hashCode * 486187739) + m_ZFar.GetHashCode(); hashCode = (hashCode * 486187739) + m_ScreenWidth.GetHashCode(); hashCode = (hashCode * 486187739) + m_ScreenHeight.GetHashCode(); hashCode = (hashCode * 486187739) + ((int)m_ScreenOrientation).GetHashCode(); } return hashCode; } /// /// Generates a string representation of this . /// /// A string representation of this . public override string ToString() { return string.Format("zNear:{0} zFar:{1} screen:{2}x{3}({4})", m_ZNear.ToString("0.000"), m_ZFar.ToString("0.000"), m_ScreenWidth.ToString(), m_ScreenHeight.ToString(), m_ScreenOrientation.ToString()); } } }