using System;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Descriptor for the . Describes capabilities of a specific raycast provider.
///
public sealed class XRRaycastSubsystemDescriptor : SubsystemDescriptor
{
///
/// Used to register a descriptor. See .
///
public struct Cinfo : IEquatable
{
///
/// A provider-specific identifier.
///
public string id { get; set; }
///
/// The Type of the subsystem.
///
public Type subsystemImplementationType { get; set; }
///
/// Whether the provider supports casting a ray from a screen point.
///
public bool supportsViewportBasedRaycast { get; set; }
///
/// Whether the provider supports casting an arbitrary ray.
///
public bool supportsWorldBasedRaycast { get; set; }
///
/// The types of trackables against which raycasting is supported.
///
public TrackableType supportedTrackableTypes { get; set; }
public override int GetHashCode()
{
unchecked
{
var hash = (id == null) ? 0 : id.GetHashCode();
hash = hash * 486187739 + ((subsystemImplementationType == null) ? 0 : subsystemImplementationType.GetHashCode());
hash = hash * 486187739 + supportsViewportBasedRaycast.GetHashCode();
hash = hash * 486187739 + supportsWorldBasedRaycast.GetHashCode();
hash = hash * 486187739 + supportedTrackableTypes.GetHashCode();
return hash;
}
}
public override bool Equals(object obj)
{
if (!(obj is Cinfo))
return false;
return Equals((Cinfo)obj);
}
public override string ToString()
{
return string.Format("XRRaycastSubsystemDescriptor:\nsupportsViewportBasedRaycast: {0}\nsupportsWorldBasedRaycast: {1}",
supportsViewportBasedRaycast, supportsWorldBasedRaycast);
}
public bool Equals(Cinfo other)
{
return
String.Equals(id, other.id) &&
(subsystemImplementationType == other.subsystemImplementationType) &&
(supportsViewportBasedRaycast == other.supportsViewportBasedRaycast) &&
(supportsWorldBasedRaycast == other.supportsWorldBasedRaycast) &&
(supportedTrackableTypes == other.supportedTrackableTypes);
}
public static bool operator ==(Cinfo lhs, Cinfo rhs) { return lhs.Equals(rhs); }
public static bool operator !=(Cinfo lhs, Cinfo rhs) { return !lhs.Equals(rhs); }
}
///
/// Whether the provider supports casting a ray from a screen point.
///
public bool supportsViewportBasedRaycast { get; private set; }
///
/// Whether the provider supports casting an arbitrary ray.
///
public bool supportsWorldBasedRaycast { get; private set; }
///
/// The types of trackables against which raycasting is supported.
///
public TrackableType supportedTrackableTypes { get; private set; }
///
/// Registers a new descriptor. Should be called by provider implementations.
///
///
public static void RegisterDescriptor(Cinfo cinfo)
{
SubsystemRegistration.CreateDescriptor(new XRRaycastSubsystemDescriptor(cinfo));
}
XRRaycastSubsystemDescriptor(Cinfo cinfo)
{
id = cinfo.id;
subsystemImplementationType = cinfo.subsystemImplementationType;
supportsViewportBasedRaycast = cinfo.supportsViewportBasedRaycast;
supportsWorldBasedRaycast = cinfo.supportsWorldBasedRaycast;
supportedTrackableTypes = cinfo.supportedTrackableTypes;
}
}
}