using System;
using System.Runtime.InteropServices;
using System.Text;
namespace UnityEngine.XR.ARKit
{
///
/// Read-only struct that stores lens position value of camera focus.
///
[StructLayout(LayoutKind.Sequential)]
public struct ARKitFocus : IEquatable
{
float m_LensPosition;
///
/// The lens position value. The value doesn't correspond to an exact physical distance of the lens. The range
/// of possible positions is 0.0 to 1.0, with 0.0 being the shortest distance at which the lens can focus and
/// 1.0 the furthest. Note that 1.0 doesn't represent focus at infinity.
///
public float lensPosition => m_LensPosition;
///
/// Constructs an instance with given lens position value.
///
/// The lens position value, between 0 and 1. Refer to
/// for more information.
public ARKitFocus(float lensPosition)
{
m_LensPosition = lensPosition;
}
///
/// Tests for equality.
///
///
/// Two s are considered equal if their lens position value is equal.
///
/// The to compare against.
/// if the lens position value is equal. Otherwise, .
public bool Equals(ARKitFocus other)
{
return m_LensPosition.Equals(other.m_LensPosition);
}
///
/// 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 ARKitFocus 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_LensPosition.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 ==(ARKitFocus lhs, ARKitFocus 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 !=(ARKitFocus lhs, ARKitFocus 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($" Lens Position: {m_LensPosition:0.000}");
sb.AppendLine("}");
return sb.ToString();
}
}
}