XRSupportUtil.cs
1.77 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
69
70
71
72
73
74
75
76
77
78
79
using UnityEngine;
#if UNITY_5
using UnityEngine.VR;
#else
using UnityEngine.XR;
#endif
namespace Leap.Unity {
/// <summary>
/// Wraps various (but not all) "XR" calls with Unity 5.6-supporting "VR" calls
/// via #ifdefs.
/// </summary>
public static class XRSupportUtil {
public static bool IsXREnabled() {
#if UNITY_5
return VRSettings.enabled;
#else
return XRSettings.enabled;
#endif
}
public static bool IsXRDevicePresent() {
#if UNITY_5
return VRDevice.isPresent;
#else
return XRDevice.isPresent;
#endif
}
public static Vector3 GetXRNodeCenterEyeLocalPosition() {
#if UNITY_5
return InputTracking.GetLocalPosition(UnityEngine.VR.VRNode.CenterEye);
#else
return InputTracking.GetLocalPosition(XRNode.CenterEye);
#endif
}
public static Quaternion GetXRNodeCenterEyeLocalRotation() {
#if UNITY_5
return InputTracking.GetLocalRotation(VRNode.CenterEye);
#else
return InputTracking.GetLocalRotation(XRNode.CenterEye);
#endif
}
public static Vector3 GetXRNodeHeadLocalPosition() {
#if UNITY_5
return InputTracking.GetLocalPosition(VRNode.Head);
#else
return InputTracking.GetLocalPosition(XRNode.Head);
#endif
}
public static Quaternion GetXRNodeHeadLocalRotation() {
#if UNITY_5
return InputTracking.GetLocalRotation(VRNode.Head);
#else
return InputTracking.GetLocalRotation(XRNode.Head);
#endif
}
public static void Recenter() {
InputTracking.Recenter();
}
public static string GetLoadedDeviceName() {
#if UNITY_5
return VRSettings.loadedDeviceName;
#else
return XRSettings.loadedDeviceName;
#endif
}
}
}