using System;
namespace UnityEngine.XR.ARFoundation
{
///
/// Event arguments for .
///
public struct ARSessionStateChangedEventArgs : IEquatable
{
///
/// The new session state.
///
public ARSessionState state { get; private set; }
///
/// Constructor for these event arguments.
///
/// The new session state.
public ARSessionStateChangedEventArgs(ARSessionState state)
{
this.state = state;
}
///
/// 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)state).GetHashCode();
///
/// Tests for equality.
///
/// The `object` to compare against.
/// `True` if is of type and
/// also returns `true`; otherwise `false`.
public override bool Equals(object obj)
{
return obj is ARSessionStateChangedEventArgs args && Equals(args);
}
///
/// Generates a string representation of this .
///
/// A string representation of this .
public override string ToString() => state.ToString();
///
/// Tests for equality.
///
/// The other to compare against.
/// `True` if every field in is equal to this , otherwise false.
public bool Equals(ARSessionStateChangedEventArgs other)
{
return state == other.state;
}
///
/// 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 ==(ARSessionStateChangedEventArgs lhs, ARSessionStateChangedEventArgs rhs)
{
return 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 !=(ARSessionStateChangedEventArgs lhs, ARSessionStateChangedEventArgs rhs)
{
return !lhs.Equals(rhs);
}
}
}