CameraFacingDirection.cs
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System.ComponentModel;
using UnityEngine.XR.ARSubsystems;
namespace UnityEngine.XR.ARFoundation
{
/// <summary>
/// Represents the camera used when supplying the video feed.
/// </summary>
public enum CameraFacingDirection
{
/// <summary>
/// No video feed should be provided.
/// </summary>
[Description("No textures will be available.")]
None,
/// <summary>
/// Provide the video feed from the world-facing camera. On a phone, this
/// is usually the rear camera.
/// </summary>
[Description("Textures from the world-facing camera will be available.")]
World,
/// <summary>
/// Provide the video feed from the user-facing camera. On a phone,
/// this is usually the front (i.e., "selfie") camera.
/// </summary>
[Description("Textures from the user-facing camera will be available.")]
User,
}
/// <summary>
/// Extensions related to the <see cref="CameraFacingDirection"/> enum.
/// </summary>
public static class CameraModeExtensions
{
/// <summary>
/// Converts <paramref name="self"/> to a <see cref="CameraFacingDirection"/>.
/// </summary>
/// <param name="self">The <c>Feature</c> being extended.</param>
/// <returns>The <see cref="CameraFacingDirection"/> represented by <paramref name="self"/>.</returns>
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;
}
}
/// <summary>
/// Converts <paramref name="self"/> to a <c>Feature</c>.
/// </summary>
/// <param name="self">The <see cref="CameraFacingDirection"/> being extended.</param>
/// <returns>The <c>Feature</c> representation of the camera facing direction.</returns>
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;
}
}
}
}