using System; using UnityEngine.SubsystemsImplementation; namespace UnityEngine.XR.ARSubsystems { /// /// Describes the capabilities of an . /// public class XRPlaneSubsystemDescriptor : SubsystemDescriptorWithProvider { /// /// true if the subsystem supports horizontal plane detection. /// public bool supportsHorizontalPlaneDetection { get; private set; } /// /// true if the subsystem supports vertical plane detection. /// public bool supportsVerticalPlaneDetection { get; private set; } /// /// true if the subsystem supports arbitrarily angled plane detection. /// public bool supportsArbitraryPlaneDetection { get; private set; } /// /// true if the subsystem supports boundary vertices for its planes. /// public bool supportsBoundaryVertices { get; private set; } /// /// true if the current subsystem supports plane classification. Otherwise, false. /// public bool supportsClassification { get; private set; } /// /// Constructor info used to register a descriptor. /// public struct Cinfo : IEquatable { /// /// The string identifier for a specific implementation. /// public string id { get; set; } /// /// Specifies the provider implementation type to use for instantiation. /// /// /// The provider implementation type to use for instantiation. /// public Type providerType { get; set; } /// /// Specifies the XRPlaneSubsystem-derived type that forwards casted calls to its provider. /// /// /// The type of the subsystem to use for instantiation. If null, XRPlaneSubsystem will be instantiated. /// public Type subsystemTypeOverride { get; set; } /// /// The concrete Type which will be instantiated if Create is called on this subsystem descriptor. /// [Obsolete("XRPlaneSubsystem no longer supports the deprecated set of base classes for subsystems as of Unity 2020.2. Use providerType and, optionally, subsystemTypeOverride instead.", true)] public Type subsystemImplementationType { get; set; } /// /// true if the subsystem supports horizontal plane detection. /// public bool supportsHorizontalPlaneDetection { get; set; } /// /// true if the subsystem supports vertical plane detection. /// public bool supportsVerticalPlaneDetection { get; set; } /// /// true if the subsystem supports arbitrarily angled plane detection. /// public bool supportsArbitraryPlaneDetection { get; set; } /// /// true if the subsystem supports boundary vertices for its planes. /// public bool supportsBoundaryVertices { get; set; } /// /// true if the subsystem supports boundary vertices for its planes. /// public bool supportsClassification { get; set; } /// /// Tests for equality. /// /// The other to compare against. /// `True` if every field in is equal to this , otherwise false. public bool Equals(Cinfo other) { return ReferenceEquals(id, other.id) && ReferenceEquals(providerType, other.providerType) && ReferenceEquals(subsystemTypeOverride, other.subsystemTypeOverride) && supportsHorizontalPlaneDetection == other.supportsHorizontalPlaneDetection && supportsVerticalPlaneDetection == other.supportsVerticalPlaneDetection && supportsArbitraryPlaneDetection == other.supportsArbitraryPlaneDetection && supportsClassification == other.supportsClassification && supportsBoundaryVertices == other.supportsBoundaryVertices; } /// /// 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) { if (!(obj is Cinfo)) return false; return Equals((Cinfo)obj); } /// /// 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() { unchecked { int hashCode = HashCodeUtil.ReferenceHash(id); hashCode = (hashCode * 486187739) + HashCodeUtil.ReferenceHash(providerType); hashCode = (hashCode * 486187739) + HashCodeUtil.ReferenceHash(subsystemTypeOverride); hashCode = (hashCode * 486187739) + supportsHorizontalPlaneDetection.GetHashCode(); hashCode = (hashCode * 486187739) + supportsVerticalPlaneDetection.GetHashCode(); hashCode = (hashCode * 486187739) + supportsArbitraryPlaneDetection.GetHashCode(); hashCode = (hashCode * 486187739) + supportsBoundaryVertices.GetHashCode(); hashCode = (hashCode * 486187739) + supportsClassification.GetHashCode(); return hashCode; } } /// /// 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 ==(Cinfo lhs, Cinfo 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 !=(Cinfo lhs, Cinfo rhs) => !lhs.Equals(rhs); } /// /// Creates a new subsystem descriptor and registers it with the SubsystemManager. /// /// Construction info for the descriptor. public static void Create(Cinfo cinfo) { var descriptor = new XRPlaneSubsystemDescriptor(cinfo); SubsystemDescriptorStore.RegisterDescriptor(descriptor); } XRPlaneSubsystemDescriptor(Cinfo cinfo) { id = cinfo.id; providerType = cinfo.providerType; subsystemTypeOverride = cinfo.subsystemTypeOverride; supportsHorizontalPlaneDetection = cinfo.supportsHorizontalPlaneDetection; supportsVerticalPlaneDetection = cinfo.supportsVerticalPlaneDetection; supportsArbitraryPlaneDetection = cinfo.supportsArbitraryPlaneDetection; supportsBoundaryVertices = cinfo.supportsBoundaryVertices; supportsClassification = cinfo.supportsClassification; } } }