using System;
using UnityEngine.SubsystemsImplementation;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Constructor info for the .
///
public struct XRHumanBodySubsystemCinfo : IEquatable
{
///
/// Specifies an identifier for the provider implementation of the subsystem.
///
///
/// The identifier for the provider implementation of the subsystem.
///
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 XRHumanBodySubsystem-derived type that forwards casted calls to its provider.
///
///
/// The type of the subsystem to use for instantiation. If null, XRHumanBodySubsystem will be instantiated.
///
public Type subsystemTypeOverride { get; set; }
///
/// Specifies the provider implementation type to use for instantiation.
///
///
/// Specifies the provider implementation type to use for instantiation.
///
[Obsolete("XRHumanBodySubsystem 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 implementationType { get; set; }
///
/// Specifies if the current subsystem supports 2D human body pose estimation.
///
///
/// true if the current subsystem supports 2D human body pose estimation. Otherwise, false.
///
public bool supportsHumanBody2D { get; set; }
///
/// Specifies if the current subsystem supports 3D human body pose estimation.
///
///
/// true if the current subsystem supports 3D human body pose estimation. Otherwise, false.
///
public bool supportsHumanBody3D { get; set; }
///
/// Specifies if the current subsystem supports 3D human body scale estimation.
///
///
/// true if the current subsystem supports 3D human body scale estimation. Otherwise, false.
///
public bool supportsHumanBody3DScaleEstimation { get; set; }
///
/// Tests for equality.
///
/// The other to compare against.
/// `True` if every field in is equal to this , otherwise false.
public bool Equals(XRHumanBodySubsystemCinfo other)
{
return
ReferenceEquals(id, other.id)
&& ReferenceEquals(providerType, other.providerType)
&& ReferenceEquals(subsystemTypeOverride, subsystemTypeOverride)
&& supportsHumanBody2D.Equals(other.supportsHumanBody2D)
&& supportsHumanBody3D.Equals(other.supportsHumanBody3D)
&& supportsHumanBody3DScaleEstimation.Equals(other.supportsHumanBody3DScaleEstimation);
}
///
/// Tests for equality.
///
/// The `object` to compare against.
/// `True` if is of type and
/// also returns `true`; otherwise `false`.
public override bool Equals(System.Object obj)
{
return ((obj is XRHumanBodySubsystemCinfo) && Equals((XRHumanBodySubsystemCinfo)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 ==(XRHumanBodySubsystemCinfo lhs, XRHumanBodySubsystemCinfo rhs)
{
return 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 !=(XRHumanBodySubsystemCinfo lhs, XRHumanBodySubsystemCinfo rhs)
{
return !lhs.Equals(rhs);
}
///
/// 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()
{
int hashCode = 486187739;
unchecked
{
hashCode = (hashCode * 486187739) + HashCodeUtil.ReferenceHash(id);
hashCode = (hashCode * 486187739) + HashCodeUtil.ReferenceHash(providerType);
hashCode = (hashCode * 486187739) + HashCodeUtil.ReferenceHash(subsystemTypeOverride);
hashCode = (hashCode * 486187739) + supportsHumanBody2D.GetHashCode();
hashCode = (hashCode * 486187739) + supportsHumanBody3D.GetHashCode();
hashCode = (hashCode * 486187739) + supportsHumanBody3DScaleEstimation.GetHashCode();
}
return hashCode;
}
}
///
/// The descriptor for the .
///
public class XRHumanBodySubsystemDescriptor : SubsystemDescriptorWithProvider
{
XRHumanBodySubsystemDescriptor(XRHumanBodySubsystemCinfo humanBodySubsystemCinfo)
{
id = humanBodySubsystemCinfo.id;
providerType = humanBodySubsystemCinfo.providerType;
subsystemTypeOverride = humanBodySubsystemCinfo.subsystemTypeOverride;
supportsHumanBody2D = humanBodySubsystemCinfo.supportsHumanBody2D;
supportsHumanBody3D = humanBodySubsystemCinfo.supportsHumanBody3D;
supportsHumanBody3DScaleEstimation = humanBodySubsystemCinfo.supportsHumanBody3DScaleEstimation;
}
///
/// Specifies if the current subsystem supports 2D human body pose estimation.
///
///
/// true if the current subsystem supports 2D human body pose estimation. Otherwise, false.
///
public bool supportsHumanBody2D { get; private set; }
///
/// Specifies if the current subsystem supports 3D human body pose estimation.
///
///
/// true if the current subsystem supports 3D human body pose estimation. Otherwise, false.
///
public bool supportsHumanBody3D { get; private set; }
///
/// Specifies if the current subsystem supports 3D human body scale estimation.
///
///
/// true if the current subsystem supports 3D human body scale estimation. Otherwise, false.
///
public bool supportsHumanBody3DScaleEstimation { get; private set; }
internal static XRHumanBodySubsystemDescriptor Create(XRHumanBodySubsystemCinfo humanBodySubsystemCinfo)
{
if (String.IsNullOrEmpty(humanBodySubsystemCinfo.id))
{
throw new ArgumentException("Cannot create human body subsystem descriptor because id is invalid",
"humanBodySubsystemCinfo");
}
if (humanBodySubsystemCinfo.providerType == null
|| !humanBodySubsystemCinfo.providerType.IsSubclassOf(typeof(XRHumanBodySubsystem.Provider)))
{
throw new ArgumentException("Cannot create human body subsystem descriptor because providerType is invalid",
"humanBodySubsystemCinfo");
}
if (humanBodySubsystemCinfo.subsystemTypeOverride != null
&& !humanBodySubsystemCinfo.subsystemTypeOverride.IsSubclassOf(typeof(XRHumanBodySubsystem)))
{
throw new ArgumentException("Cannot create human body subsystem descriptor because subsystemTypeOverride is invalid",
"humanBodySubsystemCinfo");
}
return new XRHumanBodySubsystemDescriptor(humanBodySubsystemCinfo);
}
}
}