using System;
using UnityEngine.SubsystemsImplementation;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Describes the capabilities of an .
///
public class XRImageTrackingSubsystemDescriptor : SubsystemDescriptorWithProvider
{
///
/// 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.
///
///
/// The provider implementation type to use for instantiation.
///
public Type providerType { get; set; }
///
/// Specifies the XRImageTrackingSubsystem-derived type that forwards casted calls to its provider.
///
///
/// The type of the subsystem to use for instantiation. If null, XRImageTrackingSubsystem will be instantiated.
///
public Type subsystemTypeOverride { get; set; }
///
/// The System.Type of the provider implementation, used to instantiate the class.
///
[Obsolete("XRImageTrackingSubsystem 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; }
///
/// Whether the subsystem supports tracking the poses of moving images in realtime.
///
///
/// If true,
/// and
///
/// should be implemented.
///
public bool supportsMovingImages { get; set; }
///
/// Whether the subsystem requires physical image dimensions to be provided for all reference images.
/// If false, specifying the physical dimensions is optional.
///
public bool requiresPhysicalImageDimensions { get; set; }
///
/// Whether the subsystem supports image libraries that can be mutated at runtime.
///
///
/// If true,
///
/// must be implemented and
///
/// will never be called.
///
///
public bool supportsMutableLibrary { get; set; }
///
/// Whether the subsystem supports image validation (validating images before they are added to a
/// ).
///
public bool supportsImageValidation { 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 = HashCodeUtil.ReferenceHash(id);
hashCode = hashCode * 486187739 + HashCodeUtil.ReferenceHash(providerType);
hashCode = hashCode * 486187739 + HashCodeUtil.ReferenceHash(subsystemTypeOverride);
hashCode = hashCode * 486187739 + supportsMovingImages.GetHashCode();
hashCode = hashCode * 486187739 + requiresPhysicalImageDimensions.GetHashCode();
hashCode = hashCode * 486187739 + supportsMutableLibrary.GetHashCode();
hashCode = hashCode * 486187739 + supportsImageValidation.GetHashCode();
return hashCode;
}
}
///
/// 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) &&
supportsMovingImages == other.supportsMovingImages &&
requiresPhysicalImageDimensions == other.requiresPhysicalImageDimensions &&
supportsMutableLibrary == other.supportsMutableLibrary &&
supportsImageValidation == other.supportsImageValidation;
}
///
/// 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 Cinfo) && Equals((Cinfo)obj);
///
/// 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);
}
///
/// True if the subsystem supports tracking the poses of moving images in real time.
///
public bool supportsMovingImages { get; }
///
/// True if the subsystem requires physical image dimensions to be provided for all reference images.
/// If false, specifying the physical dimensions is optional.
///
public bool requiresPhysicalImageDimensions { get; }
///
/// Whether the subsystem supports , a reference
/// image library which can modified at runtime, as opposed to the ,
/// which is generated at edit time and cannot be modified at runtime.
///
///
///
public bool supportsMutableLibrary { get; }
///
/// Whether the subsystem supports image validation (validating images before they are added to a
/// ).
///
public bool supportsImageValidation { get; }
///
/// Registers a new descriptor with the SubsystemManager.
///
/// The construction information for the new descriptor.
public static void Create(Cinfo cinfo)
{
SubsystemDescriptorStore.RegisterDescriptor(new XRImageTrackingSubsystemDescriptor(cinfo));
}
XRImageTrackingSubsystemDescriptor(Cinfo cinfo)
{
id = cinfo.id;
providerType = cinfo.providerType;
subsystemTypeOverride = cinfo.subsystemTypeOverride;
supportsMovingImages = cinfo.supportsMovingImages;
requiresPhysicalImageDimensions = cinfo.requiresPhysicalImageDimensions;
supportsMutableLibrary = cinfo.supportsMutableLibrary;
supportsImageValidation = cinfo.supportsImageValidation;
}
}
}