using System.ComponentModel;
using UnityEngine.XR.ARSubsystems;
namespace UnityEngine.XR.ARFoundation
{
///
/// Represents the camera used when supplying the video feed.
///
public enum CameraFacingDirection
{
///
/// No video feed should be provided.
///
[Description("No textures will be available.")]
None,
///
/// Provide the video feed from the world-facing camera. On a phone, this
/// is usually the rear camera.
///
[Description("Textures from the world-facing camera will be available.")]
World,
///
/// Provide the video feed from the user-facing camera. On a phone,
/// this is usually the front ("selfie") camera.
///
[Description("Textures from the user-facing camera will be available.")]
User,
}
///
/// Extensions related to the enum.
///
public static class CameraModeExtensions
{
///
/// Converts to a .
///
/// The Feature being extended.
/// The represented by .
public static CameraFacingDirection ToCameraFacingDirection(this Feature self)
{
var cameraModes = self.Cameras();
switch (cameraModes)
{
case Feature.UserFacingCamera: return CameraFacingDirection.User;
case Feature.WorldFacingCamera: return CameraFacingDirection.World;
default: return CameraFacingDirection.None;
}
}
///
/// Converts to a Feature.
///
/// The being extended.
/// The Feature representation of the camera facing direction.
public static Feature ToFeature(this CameraFacingDirection self)
{
switch (self)
{
case CameraFacingDirection.World: return Feature.WorldFacingCamera;
case CameraFacingDirection.User: return Feature.UserFacingCamera;
default: return Feature.None;
}
}
}
}