using System; using System.Runtime.InteropServices; namespace UnityEngine.XR.ARSubsystems { // Removing from summary of the configuration class because this has yet to be ported. // The camera image configuration affects the resolution of the image // returned by . /// /// Contains information regarding the camera configuration. Different /// devices support different camera configurations. This includes /// the resolution of the image and may include framerate on some platforms. /// [StructLayout(LayoutKind.Sequential)] public struct XRCameraConfiguration : IEquatable { Vector2Int m_Resolution; int m_Framerate; /// /// The width of the camera resolution /// /// /// The width, in pixels, of the camera resolution /// public int width => m_Resolution.x; /// /// The height of the camera resolution /// /// /// The height, in pixels, of the camera resolution /// public int height => m_Resolution.y; /// /// The camera resolution. /// /// /// The camera resolution in pixels. /// public Vector2Int resolution => m_Resolution; /// /// The framerate, if this camera configuration specifies one. /// /// /// The framerate, if this camera configuration specifies one. Otherwise, null. /// /// /// On some platforms, different resolutions may affect the available framerate. /// public int? framerate => (m_Framerate > 0) ? new int?(m_Framerate) : new int?(); /// /// Constructs a camera configuration with a framerate. /// /// The resolution of the camera image. /// The camera framerate. Throws ArgumentOutOfRangeException /// if is less than or equal to zero. internal XRCameraConfiguration(Vector2Int resolution, int framerate) { if (framerate <= 0) throw new ArgumentOutOfRangeException( string.Format("{0} is not a valid framerate; it must be greater than zero.", framerate)); m_Resolution = resolution; m_Framerate = framerate; } /// /// Constructs a camera configuration without a framerate. /// /// The resolution of the camera image. internal XRCameraConfiguration(Vector2Int resolution) { m_Resolution = resolution; m_Framerate = 0; } /// /// Converts the configuration to a string, suitable for debug logging. /// /// public override string ToString() => $"{width}x{height}" + (framerate.HasValue ? $" at {framerate.Value} Hz" : ""); public override int GetHashCode() { unchecked { var hash = m_Resolution.GetHashCode(); return hash * 486187739 + framerate.GetHashCode(); } } public override bool Equals(System.Object obj) => ((obj is XRCameraConfiguration) && Equals((XRCameraConfiguration)obj)); public bool Equals(XRCameraConfiguration other) => (m_Resolution == other.m_Resolution) && (framerate == other.framerate); public static bool operator ==(XRCameraConfiguration lhs, XRCameraConfiguration rhs) => lhs.Equals(rhs); public static bool operator !=(XRCameraConfiguration lhs, XRCameraConfiguration rhs) => !lhs.Equals(rhs); } }