using System;
using UnityEngine.SubsystemsImplementation;
namespace UnityEngine.XR.ARSubsystems
{
///
/// Contains the parameters for creating a new .
///
public struct XRCameraSubsystemCinfo : 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 XRCameraSubsystem-derived type that forwards casted calls to its provider.
///
///
/// The type of the subsystem to use for instantiation. If null, XRCameraSubsystem will be instantiated.
///
public Type subsystemTypeOverride { get; set; }
///
/// Specifies the provider implementation type to use for instantiation.
///
///
/// The provider implementation type to use for instantiation.
///
[Obsolete("XRCameraSubsystem 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 is allowed to provide the average brightness.
///
///
/// true if the current subsystem is allowed to provide the average brightness. Otherwise, false.
///
public bool supportsAverageBrightness { get; set; }
///
/// Specifies if the current subsystem is allowed to provide the average camera temperature.
///
///
/// true if the current subsystem is allowed to provide the average camera temperature. Otherwise, false.
///
public bool supportsAverageColorTemperature { get; set; }
///
/// True if color correction is supported.
///
public bool supportsColorCorrection { get; set; }
///
/// Specifies if the current subsystem is allowed to provide a display matrix.
///
///
/// true if the current subsystem is allowed to provide a display matrix. Otherwise, false.
///
public bool supportsDisplayMatrix { get; set; }
///
/// Specifies if the current subsystem is allowed to provide a projection matrix.
///
///
/// true if the current subsystem is allowed to provide a projection matrix. Otherwise, false.
///
public bool supportsProjectionMatrix { get; set; }
///
/// Specifies if the current subsystem is allowed to provide a timestamp.
///
///
/// true if the current subsystem is allowed to provide a timestamp. Otherwise, false.
///
public bool supportsTimestamp { get; set; }
///
/// Specifies if the current subsystem supports camera configurations.
///
///
/// true if the current subsystem supports camera configurations. Otherwise, false.
///
public bool supportsCameraConfigurations { get; set; }
///
/// Specifies if the current subsystem is allowed to provide camera images.
///
///
/// true if the current subsystem is allowed to provide camera images. Otherwise, false.
///
public bool supportsCameraImage { get; set; }
///
/// Specifies if current subsystem is allowed to provide the average intensity in lumens.
///
///
/// true if current subsystem is allowed to provide the average intensity in lumens. Otherwise, false.
///
public bool supportsAverageIntensityInLumens { get; set; }
///
/// Specifies whether the subsystem supports ambient intensity light estimation while face tracking.
///
public bool supportsFaceTrackingAmbientIntensityLightEstimation { get; set; }
///
/// Specifies whether the subsystem supports HDR light estimation while face tracking.
///
public bool supportsFaceTrackingHDRLightEstimation { get; set; }
///
/// Specifies whether the subsystem supports ambient intensity light estimation while world tracking.
///
public bool supportsWorldTrackingAmbientIntensityLightEstimation { get; set; }
///
/// Specifies whether the subsystem supports HDR light estimation while world tracking.
///
public bool supportsWorldTrackingHDRLightEstimation { get; set; }
///
/// Specifies whether the subsystem supports setting the camera's focus mode.
///
public bool supportsFocusModes { get; set; }
///
/// Specifies whether the subsystem supports a camera grain effect.
///
public bool supportsCameraGrain { get; set; }
///
/// Tests for equality.
///
/// The other to compare against.
/// `True` if every field in is equal to this , otherwise false.
public bool Equals(XRCameraSubsystemCinfo other)
{
return
ReferenceEquals(id, other.id)
&& ReferenceEquals(providerType, other.providerType)
&& ReferenceEquals(subsystemTypeOverride, other.subsystemTypeOverride)
&& supportsAverageBrightness.Equals(other.supportsAverageBrightness)
&& supportsAverageColorTemperature.Equals(other.supportsAverageColorTemperature)
&& supportsColorCorrection.Equals(other.supportsColorCorrection)
&& supportsDisplayMatrix.Equals(other.supportsDisplayMatrix)
&& supportsProjectionMatrix.Equals(other.supportsProjectionMatrix)
&& supportsTimestamp.Equals(other.supportsTimestamp)
&& supportsCameraConfigurations.Equals(other.supportsCameraConfigurations)
&& supportsCameraImage.Equals(other.supportsCameraImage)
&& supportsAverageIntensityInLumens.Equals(other.supportsAverageIntensityInLumens)
&& supportsFaceTrackingAmbientIntensityLightEstimation.Equals(other.supportsFaceTrackingAmbientIntensityLightEstimation)
&& supportsFaceTrackingHDRLightEstimation.Equals(other.supportsFaceTrackingHDRLightEstimation)
&& supportsWorldTrackingAmbientIntensityLightEstimation.Equals(other.supportsWorldTrackingAmbientIntensityLightEstimation)
&& supportsWorldTrackingHDRLightEstimation.Equals(other.supportsWorldTrackingHDRLightEstimation)
&& supportsFocusModes.Equals(other.supportsFocusModes)
&& supportsCameraGrain.Equals(other.supportsCameraGrain);
}
///
/// 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 XRCameraSubsystemCinfo) && Equals((XRCameraSubsystemCinfo)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 ==(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo 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 !=(XRCameraSubsystemCinfo lhs, XRCameraSubsystemCinfo rhs) => !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) + supportsAverageBrightness.GetHashCode();
hashCode = (hashCode * 486187739) + supportsAverageColorTemperature.GetHashCode();
hashCode = (hashCode * 486187739) + supportsColorCorrection.GetHashCode();
hashCode = (hashCode * 486187739) + supportsDisplayMatrix.GetHashCode();
hashCode = (hashCode * 486187739) + supportsProjectionMatrix.GetHashCode();
hashCode = (hashCode * 486187739) + supportsTimestamp.GetHashCode();
hashCode = (hashCode * 486187739) + supportsCameraConfigurations.GetHashCode();
hashCode = (hashCode * 486187739) + supportsCameraImage.GetHashCode();
hashCode = (hashCode * 486187739) + supportsAverageIntensityInLumens.GetHashCode();
hashCode = (hashCode * 486187739) + supportsFaceTrackingAmbientIntensityLightEstimation.GetHashCode();
hashCode = (hashCode * 486187739) + supportsFaceTrackingHDRLightEstimation.GetHashCode();
hashCode = (hashCode * 486187739) + supportsWorldTrackingAmbientIntensityLightEstimation.GetHashCode();
hashCode = (hashCode * 486187739) + supportsWorldTrackingHDRLightEstimation.GetHashCode();
hashCode = (hashCode * 486187739) + supportsFocusModes.GetHashCode();
hashCode = (hashCode * 486187739) + supportsCameraGrain.GetHashCode();
}
return hashCode;
}
}
///
/// Specifies a functionality description that can be registered for each implementation that provides the
/// interface.
///
public sealed class XRCameraSubsystemDescriptor :
SubsystemDescriptorWithProvider
{
///
/// Constructs a XRCameraSubsystemDescriptor based on the given parameters.
///
/// The parameters required to initialize the descriptor.
XRCameraSubsystemDescriptor(XRCameraSubsystemCinfo cameraSubsystemParams)
{
id = cameraSubsystemParams.id;
providerType = cameraSubsystemParams.providerType;
subsystemTypeOverride = cameraSubsystemParams.subsystemTypeOverride;
supportsAverageBrightness = cameraSubsystemParams.supportsAverageBrightness;
supportsAverageColorTemperature = cameraSubsystemParams.supportsAverageColorTemperature;
supportsColorCorrection = cameraSubsystemParams.supportsColorCorrection;
supportsDisplayMatrix = cameraSubsystemParams.supportsDisplayMatrix;
supportsProjectionMatrix = cameraSubsystemParams.supportsProjectionMatrix;
supportsTimestamp = cameraSubsystemParams.supportsTimestamp;
supportsCameraConfigurations = cameraSubsystemParams.supportsCameraConfigurations;
supportsCameraImage = cameraSubsystemParams.supportsCameraImage;
supportsAverageIntensityInLumens = cameraSubsystemParams.supportsAverageIntensityInLumens;
supportsFocusModes = cameraSubsystemParams.supportsFocusModes;
supportsFaceTrackingAmbientIntensityLightEstimation = cameraSubsystemParams.supportsFaceTrackingAmbientIntensityLightEstimation;
supportsFaceTrackingHDRLightEstimation = cameraSubsystemParams.supportsFaceTrackingHDRLightEstimation;
supportsWorldTrackingAmbientIntensityLightEstimation = cameraSubsystemParams.supportsWorldTrackingAmbientIntensityLightEstimation;
supportsWorldTrackingHDRLightEstimation = cameraSubsystemParams.supportsWorldTrackingHDRLightEstimation;
supportsCameraGrain = cameraSubsystemParams.supportsCameraGrain;
}
///
/// Specifies if the current subsystem is allowed to provide the average brightness.
///
///
/// true if the current subsystem is allowed to provide the average brightness. Otherwise, false.
///
public bool supportsAverageBrightness { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide the average camera temperature.
///
///
/// true if the current subsystem is allowed to provide the average camera temperature. Otherwise, false.
///
public bool supportsAverageColorTemperature { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide color correction.
///
public bool supportsColorCorrection { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide a display matrix.
///
///
/// true if the current subsystem is allowed to provide a display matrix. Otherwise, false.
///
public bool supportsDisplayMatrix { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide a projection matrix.
///
///
/// true if the current subsystem is allowed to provide a projection matrix. Otherwise, false.
///
public bool supportsProjectionMatrix { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide the timestamp.
///
///
/// true if the current subsystem is allowed to provide the timestamp. Otherwise, false.
///
public bool supportsTimestamp { get; private set; }
///
/// Specifies if the current subsystem supports camera configurations.
///
///
/// true if the current subsystem supports camera configurations. Otherwise, false.
///
public bool supportsCameraConfigurations { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide camera images.
///
///
/// true if the current subsystem is allowed to provide camera images. Otherwise, false.
///
public bool supportsCameraImage { get; private set; }
///
/// Specifies if the current subsystem is allowed to provide the average intensity in lumens.
///
///
/// true if the current subsystem is allowed to provide the average intensity in lumens. Otherwise, false.
///
public bool supportsAverageIntensityInLumens { get; private set; }
///
/// True if the subsystem supports setting the camera's focus mode.
///
public bool supportsFocusModes { get; private set; }
///
/// True if the subsystem supports ambient intensity light estimation while face tracking.
///
public bool supportsFaceTrackingAmbientIntensityLightEstimation { get; private set; }
///
/// True if the subsystem supports HDR light estimation while face tracking.
///
public bool supportsFaceTrackingHDRLightEstimation { get; private set; }
///
/// True if the subsystem supports ambient intensity light estimation while world tracking.
///
public bool supportsWorldTrackingAmbientIntensityLightEstimation { get; private set; }
///
/// True if the subsystem supports HDR light estimation while world tracking.
///
public bool supportsWorldTrackingHDRLightEstimation { get; private set; }
///
/// True if the subsystem supports the camera grain effect.
///
public bool supportsCameraGrain { get; private set; }
///
/// Creates a XRCameraSubsystemDescriptor based on the given parameters and validates that the
/// and
/// properties are properly specified.
///
/// The parameters that define how to initialize the descriptor.
///
/// The created XRCameraSubsystemDescriptor.
///
/// Thrown when the values specified in the
/// parameter are invalid. Typically, this happens:
///
/// -
/// If is null or empty.
///
/// -
/// If is null.
///
/// -
/// If does not derive from the
/// class.
///
///
///
///
internal static XRCameraSubsystemDescriptor Create(XRCameraSubsystemCinfo cameraSubsystemParams)
{
if (String.IsNullOrEmpty(cameraSubsystemParams.id))
{
throw new ArgumentException("Cannot create camera subsystem descriptor because id is invalid",
"cameraSubsystemParams");
}
if (cameraSubsystemParams.providerType == null
|| !cameraSubsystemParams.providerType.IsSubclassOf(typeof(XRCameraSubsystem.Provider)))
{
throw new ArgumentException("Cannot create camera subsystem descriptor because providerType is invalid", "cameraSubsystemParams");
}
if (cameraSubsystemParams.subsystemTypeOverride != null
&& !cameraSubsystemParams.subsystemTypeOverride.IsSubclassOf(typeof(XRCameraSubsystem)))
{
throw new ArgumentException("Cannot create camera subsystem descriptor because subsystemTypeOverride is invalid", "cameraSubsystemParams");
}
return new XRCameraSubsystemDescriptor(cameraSubsystemParams);
}
}
}