using System; using UnityEngine.SubsystemsImplementation; using UnityEngine.XR.Hands.ProviderImplementation; namespace UnityEngine.XR.Hands { /// /// Describes the capabilities of an . /// public class XRHandSubsystemDescriptor : SubsystemDescriptorWithProvider { /// /// Whether the provider can supply aim pose. /// public bool supportsAimPose { get; } /// /// Whether the provider can supply aim activate value. /// public bool supportsAimActivateValue { get; } /// /// Whether the provider can supply grasp value. /// public bool supportsGraspValue { get; } /// /// Whether the provider can supply grip pose. /// public bool supportsGripPose { get; } /// /// Whether the provider can supply pinch pose. /// public bool supportsPinchPose { get; } /// /// Whether the provider can supply pinch value. /// public bool supportsPinchValue { get; } /// /// Whether the provider can supply poke pose. /// public bool supportsPokePose { get; } /// /// Construction information for the . /// public struct Cinfo : IEquatable { /// /// A string identifier used to name the subsystem provider. /// public string id { get; set; } /// /// Specifies the provider implementation type to use for instantiation. /// public Type providerType { get; set; } /// /// Specifies the -derived type that /// forwards casted calls to its provider. /// /// /// The type of the subsystem to use for instantiation. If null, /// will be instantiated. /// public Type subsystemTypeOverride { get; set; } /// /// Whether the provider can supply aim pose. /// public bool supportsAimPose { get; set; } /// /// Whether the provider can supply aim activate value. /// public bool supportsAimActivateValue { get; set; } /// /// Whether the provider can supply grasp value. /// public bool supportsGraspValue { get; set; } /// /// Whether the provider can supply grip pose. /// public bool supportsGripPose { get; set; } /// /// Whether the provider can supply pinch pose. /// public bool supportsPinchPose { get; set; } /// /// Whether the provider can supply pinch value. /// public bool supportsPinchValue { get; set; } /// /// Whether the provider can supply poke pose. /// public bool supportsPokePose { get; set; } /// /// 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 = id != null ? id.GetHashCode() : 0; hashCode = hashCode * 486187739 + (providerType != null ? providerType.GetHashCode() : 0); hashCode = hashCode * 486187739 + (subsystemTypeOverride != null ? subsystemTypeOverride.GetHashCode() : 0); hashCode = hashCode * 486187739 + supportsAimPose.GetHashCode(); hashCode = hashCode * 486187739 + supportsAimActivateValue.GetHashCode(); hashCode = hashCode * 486187739 + supportsGraspValue.GetHashCode(); hashCode = hashCode * 486187739 + supportsGripPose.GetHashCode(); hashCode = hashCode * 486187739 + supportsPinchPose.GetHashCode(); hashCode = hashCode * 486187739 + supportsPinchValue.GetHashCode(); hashCode = hashCode * 486187739 + supportsPokePose.GetHashCode(); return hashCode; } } /// /// Tests for equality. /// /// The other to compare against. /// /// Returns if every field in /// is equal to this , otherwise returns . /// public bool Equals(Cinfo other) { return id == other.id && providerType == other.providerType && subsystemTypeOverride == other.subsystemTypeOverride && supportsAimPose == other.supportsAimPose && supportsAimActivateValue == other.supportsAimActivateValue && supportsGraspValue == other.supportsGraspValue && supportsGripPose == other.supportsGripPose && supportsPinchPose == other.supportsPinchPose && supportsPinchValue == other.supportsPinchValue && supportsPokePose == other.supportsPokePose; } /// /// Tests for equality. /// /// The `object` to compare against. /// /// Returns if is of /// type and also /// returns ; otherwise returns . /// public override bool Equals(object obj) => (obj is Cinfo) && Equals((Cinfo)obj); /// /// Tests for equality. Same as . /// /// The left-hand side of the comparison. /// The right-hand side of the comparison. /// /// Returns if is equal /// to , otherwise returns . /// 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. /// Returns if /// is not equal to , otherwise returns /// . /// public static bool operator !=(Cinfo lhs, Cinfo rhs) => !lhs.Equals(rhs); } /// /// Registers a new descriptor with the SubsystemManager. /// /// The construction information for the new descriptor. public static void Register(Cinfo cinfo) { SubsystemDescriptorStore.RegisterDescriptor(new XRHandSubsystemDescriptor(cinfo)); } XRHandSubsystemDescriptor(Cinfo cinfo) { id = cinfo.id; providerType = cinfo.providerType; subsystemTypeOverride = cinfo.subsystemTypeOverride; supportsAimPose = cinfo.supportsAimPose; supportsAimActivateValue = cinfo.supportsAimActivateValue; supportsGraspValue = cinfo.supportsGraspValue; supportsGripPose = cinfo.supportsGripPose; supportsPinchPose = cinfo.supportsPinchPose; supportsPinchValue = cinfo.supportsPinchValue; supportsPokePose = cinfo.supportsPokePose; } } }