using System; using UnityEngine.SubsystemsImplementation; namespace UnityEngine.XR.ARSubsystems { /// /// Descriptor for the describing capabilities which may vary by implementation. /// public sealed class XRSessionSubsystemDescriptor : SubsystemDescriptorWithProvider { /// /// Whether the session supports the update or installation of session software. /// public bool supportsInstall { get; private set; } /// /// Whether the session supports matching the AR frame rate to the Unity frame rate. /// public bool supportsMatchFrameRate { get; private set; } /// /// Used in conjunction with to register a provider. /// This should only be used by subsystem implementors. /// public struct Cinfo : IEquatable { /// /// Whether the session supports the update or installation of session software. /// public bool supportsInstall { get; set; } /// /// Whether the session supports matching the AR frame rate to the Unity frame rate. /// public bool supportsMatchFrameRate { get; set; } /// /// The string used to identify this subsystem implementation. /// This will be available when enumerating the available descriptors at runtime. /// 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 XRAnchorSubsystem-derived type that forwards casted calls to its provider. /// /// /// The type of the subsystem to use for instantiation. If null, XRAnchorSubsystem will be instantiated. /// public Type subsystemTypeOverride { get; set; } /// /// The Type of the implementation. /// [Obsolete("XRSubsystem 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; } /// /// Generates a hash code suitable for use in a HashSet or Dictionary. /// /// A hash code suitable for use in a HashSet or Dictionary. public override int GetHashCode() { unchecked { int hash = HashCodeUtil.ReferenceHash(id); hash = hash * 486187739 + HashCodeUtil.ReferenceHash(providerType); hash = hash * 486187739 + HashCodeUtil.ReferenceHash(subsystemTypeOverride); hash = hash * 486187739 + supportsInstall.GetHashCode(); hash = hash * 486187739 + supportsMatchFrameRate.GetHashCode(); return hash; } } /// /// Tests for equality. /// /// The other to compare against. /// true if all fields in are equal to this , otherwise false. public bool Equals(Cinfo other) { return string.Equals(id, other.id) && ReferenceEquals(providerType, other.providerType) && ReferenceEquals(subsystemTypeOverride, other.subsystemTypeOverride) && supportsInstall == other.supportsInstall && supportsMatchFrameRate == other.supportsMatchFrameRate; } /// /// Tests for equality. /// /// The object to test for equality. /// true if is a and returns true, otherwise false. public override bool Equals(object obj) => obj is Cinfo && Equals((Cinfo)obj); /// /// Tests for equality. /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// true if is equal to . Same as . public static bool operator ==(Cinfo lhs, Cinfo rhs) => lhs.Equals(rhs); /// /// Tests for inequality. /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// true if is not equal to . Same as !. public static bool operator !=(Cinfo lhs, Cinfo rhs) => !lhs.Equals(rhs); } /// /// Register a subsystem implementation. /// This should only be used by subsystem implementors. /// /// Information used to construct the descriptor. public static void RegisterDescriptor(Cinfo cinfo) { SubsystemDescriptorStore.RegisterDescriptor(new XRSessionSubsystemDescriptor(cinfo)); } XRSessionSubsystemDescriptor(Cinfo cinfo) { id = cinfo.id; providerType = cinfo.providerType; subsystemTypeOverride = cinfo.subsystemTypeOverride; supportsInstall = cinfo.supportsInstall; supportsMatchFrameRate = cinfo.supportsMatchFrameRate; } } }