using System;
using System.Runtime.InteropServices;
using System.Text;
namespace UnityEngine.XR.ARKit
{
///
/// Read-only struct that stores exposure duration and ISO values.
///
[StructLayout(LayoutKind.Sequential)]
public struct ARKitExposure : IEquatable
{
double m_Duration;
float m_Iso;
///
/// Exposure duration in seconds with sub-millisecond precision.
///
public double duration => m_Duration;
///
/// The exposure ISO value.
///
public float iso => m_Iso;
///
/// Constructs an instance with given exposure values.
///
/// Exposure duration in seconds.
/// The ISO value.
public ARKitExposure(double duration, float iso)
{
m_Duration = duration;
m_Iso = iso;
}
///
/// Tests for equality.
///
///
/// Two s are considered equal if their duration and ISO values are equal.
///
/// The to compare against.
/// if the duration and ISO values are equal. Otherwise, .
public bool Equals(ARKitExposure other)
{
return m_Duration.Equals(other.m_Duration)
&& m_Iso.Equals(other.m_Iso);
}
///
/// Tests for equality.
///
/// An to compare against.
/// Returns if is an and is
/// equal to this instance using .
public override bool Equals(object obj)
{
return obj is ARKitExposure other
&& Equals(other);
}
///
/// Generates a hash code suitable for use with a `HashSet` or `Dictionary`
///
/// Returns a hash code for this .
public override int GetHashCode()
{
int hashCode = 486187739;
unchecked
{
hashCode = (hashCode * 486187739) + m_Duration.GetHashCode();
hashCode = (hashCode * 486187739) + m_Iso.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 ==(ARKitExposure lhs, ARKitExposure 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 !=(ARKitExposure lhs, ARKitExposure 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($" Duration: {m_Duration:0.000}");
sb.AppendLine($" ISO: {m_Iso:0.000}");
sb.AppendLine("}");
return sb.ToString();
}
}
}