using System;
namespace UnityEngine.XR.ARKit
{
///
/// Represents an asynchronous world map request.
/// Use this to determine the status of the request
/// and get the once the request is complete.
///
public struct ARWorldMapRequest : IDisposable, IEquatable
{
///
/// Get the status of the request.
///
public ARWorldMapRequestStatus status => Api.UnityARKit_getWorldMapRequestStatus(m_RequestId);
///
/// Retrieve the .
/// It is an error to call this method when is
/// not .
///
/// An representing the state of the session at the time the request was made.
public ARWorldMap GetWorldMap()
{
if (status != ARWorldMapRequestStatus.Success)
throw new InvalidOperationException("Cannot GetWorldMap unless status is ARWorldMapRequestStatus.Success.");
var worldMapId = Api.UnityARKit_getWorldMapIdFromRequestId(m_RequestId);
if (worldMapId == ARWorldMap.k_InvalidHandle)
throw new InvalidOperationException("Internal error.");
return new ARWorldMap(worldMapId);
}
///
/// Dispose of the request. You must dispose of the request to avoid
/// leaking resources.
///
public void Dispose() => Api.UnityARKit_disposeWorldMapRequest(m_RequestId);
///
/// 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() => m_RequestId.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) => obj is ARWorldMapRequest other && Equals(other);
///
/// Tests for equality.
///
/// The other to compare against.
/// `True` if every field in is equal to this , otherwise false.
public bool Equals(ARWorldMapRequest other) => m_RequestId == other.m_RequestId;
///
/// 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 ==(ARWorldMapRequest lhs, ARWorldMapRequest 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 !=(ARWorldMapRequest lhs, ARWorldMapRequest rhs) => !lhs.Equals(rhs);
internal ARWorldMapRequest(int requestId) => m_RequestId = requestId;
int m_RequestId;
}
}