TrackingMode.cs
2.19 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
using UnityEngine.XR.ARSubsystems;
namespace UnityEngine.XR.ARFoundation
{
/// <summary>
/// Represents the tracking mode for the session.
/// </summary>
public enum TrackingMode
{
/// <summary>
/// The tracking mode is not specified and will be chosen automatically.
/// </summary>
DontCare = 0,
/// <summary>
/// 3 degrees of freedom for orientation only
/// </summary>
RotationOnly = 1,
/// <summary>
/// 6 degrees of freedom including both orientation and position
/// </summary>
PositionAndRotation = 2,
}
/// <summary>
/// Extensions for the <see cref="TrackingMode"/> and <c>Feature</c> enums,
/// allowing conversion between the two.
/// </summary>
public static class TrackingModeExtensions
{
/// <summary>
/// Converts a <see cref="TrackingMode"/> to a <c>UnityEngine.XR.ARSubsystems.Feature</c>.
/// </summary>
/// <param name="self">The <see cref="TrackingMode"/> being extended.</param>
/// <returns>A <c>Feature</c> with the appropriate tracking mode bits set.</returns>
public static Feature ToFeature(this TrackingMode self)
{
switch (self)
{
case TrackingMode.RotationOnly: return Feature.RotationOnly;
case TrackingMode.PositionAndRotation: return Feature.PositionAndRotation;
default: return Feature.None;
}
}
/// <summary>
/// Converts a <c>UnityEngine.XR.ARSubsystems.Feature</c> to a <see cref="TrackingMode"/>.
/// </summary>
/// <param name="self">The <c>Feature</c> being extended.</param>
/// <returns>The <see cref="TrackingMode"/> representation of <paramref name="self"/>.</returns>
public static TrackingMode ToTrackingMode(this Feature self)
{
switch(self.TrackingModes())
{
case Feature.RotationOnly: return TrackingMode.RotationOnly;
case Feature.PositionAndRotation: return TrackingMode.PositionAndRotation;
default: return TrackingMode.DontCare;
}
}
}
}