26 private bool m_leapConnected =
false;
29 private int m_framrateUpdateCount = 0;
30 private int m_framerateUpdateInterval = 30;
32 private const bool m_startInScreenTopViewMode =
false;
34 private void FindController() {
46 .leapProvider = provider;
50 m_warningText.text =
"Please put on your head-mounted display";
53 private void goDesktop() {
59 private void goScreenTop()
71 if (m_controller !=
null)
74 if (m_startInScreenTopViewMode)
76 Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height,
false);
79 else if (XRSupportUtil.IsXRDevicePresent())
81 Screen.SetResolution(640, 480,
false);
86 Screen.SetResolution(Screen.currentResolution.width, Screen.currentResolution.height,
false);
91 m_deltaTime.
delay = 0.1f;
96 if (m_controller ==
null)
103 if (!m_leapConnected)
112 "Tracking Mode: Screen-Top (Press '{0}' to switch to desktop mode)",
123 "Tracking Mode: Head-Mounted (Press '{0}' to switch to screen-top mode)",
134 "Tracking Mode: Desktop (Press '{0}' to switch to head-mounted mode)",
144 m_deltaTime.
Update(Time.deltaTime, Time.deltaTime);
145 if (m_framrateUpdateCount > m_framerateUpdateInterval) {
146 updateRenderFrameRate();
147 m_framrateUpdateCount = 0;
149 m_framrateUpdateCount++;
152 private void updateRenderFrameRate() {
153 float msec = m_deltaTime.
value * 1000.0f;
154 float fps = 1.0f / m_deltaTime.
value;
155 string text =
string.Format(
"{0:0.0} ms ({1:0.} fps)", msec, fps);
The Controller class is your main interface to the Leap Motion Controller.
PolicyFlag
The supported controller policies.
void ClearPolicy(PolicyFlag policy)
Requests clearing a policy.
void SetPolicy(PolicyFlag policy)
Requests setting a policy.
bool IsConnected
Reports whether this Controller is connected to the Leap Motion service and the Leap Motion hardware ...
Frame Frame(int history=0)
In most cases you should get Frame objects using the LeapProvider.CurrentFrame property....
bool IsPolicySet(PolicyFlag policy)
Gets the active setting for a specific policy.
float CurrentFramesPerSecond
The instantaneous framerate.
The HandModelManager manages a pool of HandModelBases and makes HandRepresentations when a it detects...
The LeapServiceProvider provides tracked Leap Hand data and images from the device via the Leap servi...
Controller GetLeapController()
Returns the Leap Controller instance.
The LeapXRServiceProvider expands on the standard LeapServiceProvider to account for the offset of th...
Time-step independent exponential smoothing.
float Update(float input, float deltaTime=1f)
KeyCode keyToSwitchViewMode
UnityEngine.UI.Text m_dataFrameRateText
GameObject m_PCVisualizer
GameObject m_VRVisualizer
UnityEngine.UI.Text m_frameRateText
UnityEngine.UI.Text m_warningText
UnityEngine.UI.Text m_trackingText