Skip to content

Commit e754eac

Browse files
authored
Fix build break in LeapMotionDeviceManager.cs (#10570)
* Update LeapMotionDeviceManager.cs * Re-add the local LeapXRServiceProvider * Add a comment about why the local exists * Formatting and code style
1 parent 6e6d4ef commit e754eac

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

Assets/MRTK/Providers/LeapMotion/LeapMotionDeviceManager.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) Microsoft Corporation.
2-
// Licensed under the MIT License.
2+
// Licensed under the MIT License.
33

44
using Microsoft.MixedReality.Toolkit.Input;
55
using Microsoft.MixedReality.Toolkit.Utilities;
6-
using UnityEngine;
6+
using System;
77
using System.Collections.Generic;
88
using Unity.Profiling;
9-
using System;
9+
using UnityEngine;
1010

1111
#if LEAPMOTIONCORE_PRESENT
1212
using Leap;
@@ -55,27 +55,27 @@ public bool CheckCapability(MixedRealityCapability capability)
5555

5656
#if LEAPMOTIONCORE_PRESENT
5757
/// <summary>
58-
/// The profile that contains settings for the Leap Motion Device Manager input data provider. This profile is nested under
58+
/// The profile that contains settings for the Leap Motion Device Manager input data provider. This profile is nested under
5959
/// Input > Input Data Providers > Leap Motion Device Manager in the MixedRealityToolkit object in the hierarchy.
6060
/// </summary>
6161
public LeapMotionDeviceManagerProfile SettingsProfile => ConfigurationProfile as LeapMotionDeviceManagerProfile;
6262

6363
/// <summary>
64-
/// The LeapServiceProvider is added to the scene at runtime in OnEnable.
64+
/// The LeapServiceProvider is added to the scene at runtime in OnEnable.
6565
/// </summary>
6666
public LeapServiceProvider LeapMotionServiceProvider { get; protected set; }
6767

6868
/// <summary>
6969
/// The distance between the index finger tip and the thumb tip required to enter the pinch/air tap selection gesture.
70-
/// The pinch gesture enter will be registered for all values less than the EnterPinchDistance. The default EnterPinchDistance value is 0.02 and must be between 0.015 and 0.1.
70+
/// The pinch gesture enter will be registered for all values less than the EnterPinchDistance. The default EnterPinchDistance value is 0.02 and must be between 0.015 and 0.1.
7171
/// </summary>
72-
private float enterPinchDistance => SettingsProfile.EnterPinchDistance;
72+
private float EnterPinchDistance => SettingsProfile.EnterPinchDistance;
7373

7474
/// <summary>
7575
/// The distance between the index finger tip and the thumb tip required to exit the pinch/air tap gesture.
76-
/// The pinch gesture exit will be registered for all values greater than the ExitPinchDistance. The default ExitPinchDistance value is 0.05 and must be between 0.015 and 0.1.
76+
/// The pinch gesture exit will be registered for all values greater than the ExitPinchDistance. The default ExitPinchDistance value is 0.05 and must be between 0.015 and 0.1.
7777
/// </summary>
78-
private float exitPinchDistance => SettingsProfile.ExitPinchDistance;
78+
private float ExitPinchDistance => SettingsProfile.ExitPinchDistance;
7979

8080
/// <summary>
8181
/// If true, the leap motion controller is connected and detected.
@@ -90,21 +90,21 @@ public bool CheckCapability(MixedRealityCapability capability)
9090
/// <summary>
9191
/// List of hands that are currently in frame and detected by the leap motion controller. If there are no hands in the current frame, this list will be empty.
9292
/// </summary>
93-
private List<Hand> currentHandsDetectedByLeap => LeapMotionServiceProvider.CurrentFrame.Hands;
93+
private List<Hand> CurrentHandsDetectedByLeap => LeapMotionServiceProvider.CurrentFrame.Hands;
9494

9595
// This value can only be set in the profile, the default is LeapControllerOrientation.Headset.
96-
private LeapControllerOrientation leapControllerOrientation => SettingsProfile.LeapControllerOrientation;
96+
private LeapControllerOrientation LeapControllerOrientation => SettingsProfile.LeapControllerOrientation;
9797

9898
/// <summary>
9999
/// Adds an offset to the game object with LeapServiceProvider attached. This offset is only applied if the leapControllerOrientation
100-
/// is LeapControllerOrientation.Desk and is necessary for the hand to appear in front of the main camera. If the leap controller is on the
101-
/// desk, the LeapServiceProvider is added to the scene instead of the LeapXRServiceProvider. The anchor point for the position of the leap hands is
100+
/// is LeapControllerOrientation.Desk and is necessary for the hand to appear in front of the main camera. If the leap controller is on the
101+
/// desk, the LeapServiceProvider is added to the scene instead of the LeapXRServiceProvider. The anchor point for the position of the leap hands is
102102
/// the position of the game object with the LeapServiceProvider attached.
103103
/// </summary>
104-
private Vector3 leapHandsOffset => SettingsProfile.LeapControllerOffset;
104+
private Vector3 LeapHandsOffset => SettingsProfile.LeapControllerOffset;
105105

106106
// If the Leap Controller Orientation is the Headset, controller offset settings will be exposed in the inspector while using the LeapXRServiceProvider
107-
private LeapVRDeviceOffsetMode leapVRDeviceOffsetMode => SettingsProfile.LeapVRDeviceOffsetMode;
107+
private LeapVRDeviceOffsetMode LeapVRDeviceOffsetMode => SettingsProfile.LeapVRDeviceOffsetMode;
108108

109109
/// <summary>
110110
/// Dictionary to capture all active leap motion hands detected.
@@ -121,7 +121,7 @@ public override void Enable()
121121
{
122122
base.Enable();
123123

124-
if (leapControllerOrientation == LeapControllerOrientation.Headset)
124+
if (LeapControllerOrientation == LeapControllerOrientation.Headset)
125125
{
126126
// As of the Unity Plugin (>V5.0.0), the leap service provider needs to know what is the main camera,
127127
// it will pick this up from the MainCameraProvider. This needs to be done before the LeapXRServiceProvider is created
@@ -130,26 +130,26 @@ public override void Enable()
130130
MainCameraProvider.mainCamera = CameraCache.Main;
131131
#endif
132132
// If the leap controller is mounted on a headset then add the LeapXRServiceProvider to the scene
133-
LeapMotionServiceProvider = CameraCache.Main.gameObject.AddComponent<LeapXRServiceProvider>();
134-
133+
LeapXRServiceProvider leapXRServiceProvider; // This is a different type than the LeapMotionServiceProvider property for access to specific settings below.
134+
LeapMotionServiceProvider = leapXRServiceProvider = CameraCache.Main.gameObject.AddComponent<LeapXRServiceProvider>();
135+
135136
// Allow modification of VR specific offset modes if the leapControllerOrientation is Headset
136137
// These settings mirror the modification of the properties exposed in the inspector within the LeapXRServiceProvider attached
137138
// to the main camera
138-
if (leapVRDeviceOffsetMode == LeapVRDeviceOffsetMode.ManualHeadOffset)
139+
if (LeapVRDeviceOffsetMode == LeapVRDeviceOffsetMode.ManualHeadOffset)
139140
{
140-
// Change the offset mode before setting the properties
141+
// Change the offset mode before setting the properties
141142
leapXRServiceProvider.deviceOffsetMode = LeapXRServiceProvider.DeviceOffsetMode.ManualHeadOffset;
142143

143144
leapXRServiceProvider.deviceOffsetYAxis = SettingsProfile.LeapVRDeviceOffsetY;
144145
leapXRServiceProvider.deviceOffsetZAxis = SettingsProfile.LeapVRDeviceOffsetZ;
145146
leapXRServiceProvider.deviceTiltXAxis = SettingsProfile.LeapVRDeviceOffsetTiltX;
146147
}
147-
else if (leapVRDeviceOffsetMode == LeapVRDeviceOffsetMode.Transform)
148+
else if (LeapVRDeviceOffsetMode == LeapVRDeviceOffsetMode.Transform)
148149
{
149150
if (SettingsProfile.LeapVRDeviceOrigin != null)
150151
{
151152
leapXRServiceProvider.deviceOffsetMode = LeapXRServiceProvider.DeviceOffsetMode.Transform;
152-
153153
leapXRServiceProvider.deviceOrigin = SettingsProfile.LeapVRDeviceOrigin;
154154
}
155155
else
@@ -159,7 +159,7 @@ public override void Enable()
159159
}
160160
}
161161

162-
if (leapControllerOrientation == LeapControllerOrientation.Desk)
162+
if (LeapControllerOrientation == LeapControllerOrientation.Desk)
163163
{
164164
// Create a separate gameobject if the leap controller is on the desk
165165
GameObject leapProvider = new GameObject("LeapProvider");
@@ -171,7 +171,7 @@ public override void Enable()
171171
leapProvider.transform.parent = CameraCache.Main.transform;
172172

173173
// Apply hand position offset, an offset is required to render the hands in view and in front of the camera
174-
LeapMotionServiceProvider.transform.position += leapHandsOffset;
174+
LeapMotionServiceProvider.transform.position += LeapHandsOffset;
175175
}
176176

177177
// Add the attachment hands to the scene for the purpose of getting the tracking state of each hand and joint positions
@@ -208,12 +208,12 @@ public override void Disable()
208208
if (LeapMotionServiceProvider != null)
209209
{
210210
// Destroy the LeapProvider GameObject if the controller orientation is the desk
211-
if (leapControllerOrientation == LeapControllerOrientation.Desk)
211+
if (LeapControllerOrientation == LeapControllerOrientation.Desk)
212212
{
213213
GameObject.Destroy(LeapMotionServiceProvider.gameObject);
214214
}
215215
// Destroy the LeapXRServiceProvider attached to the main camera if the controller orientation is headset
216-
else if (leapControllerOrientation == LeapControllerOrientation.Headset)
216+
else if (LeapControllerOrientation == LeapControllerOrientation.Headset)
217217
{
218218
GameObject.Destroy(LeapMotionServiceProvider);
219219
}
@@ -235,8 +235,8 @@ private void OnHandDetected(Handedness handedness)
235235
var leapHand = new LeapMotionArticulatedHand(TrackingState.Tracked, handedness, inputSource);
236236

237237
// Set pinch thresholds
238-
leapHand.HandDefinition.EnterPinchDistance = enterPinchDistance;
239-
leapHand.HandDefinition.ExitPinchDistance = exitPinchDistance;
238+
leapHand.HandDefinition.EnterPinchDistance = EnterPinchDistance;
239+
leapHand.HandDefinition.ExitPinchDistance = ExitPinchDistance;
240240

241241
// Set the leap attachment hand to the corresponding handedness
242242
if (handedness == Handedness.Left)
@@ -247,7 +247,7 @@ private void OnHandDetected(Handedness handedness)
247247
{
248248
leapHand.SetAttachmentHands(rightAttachmentHand, LeapMotionServiceProvider);
249249
}
250-
250+
251251
// Set the pointers for an articulated hand to the leap hand
252252
foreach (var pointer in pointers)
253253
{
@@ -289,7 +289,7 @@ private void UpdateLeapTrackedHands(bool isLeftTracked, bool isRightTracked)
289289
if (isLeftTracked && !trackedHands.ContainsKey(Handedness.Left))
290290
{
291291
OnHandDetected(Handedness.Left);
292-
}
292+
}
293293
else if (!isLeftTracked && trackedHands.ContainsKey(Handedness.Left))
294294
{
295295
OnHandDetectionLost(Handedness.Left);
@@ -316,7 +316,7 @@ public override void Update()
316316
if (IsLeapConnected)
317317
{
318318
// if the number of tracked hands in frame has changed
319-
if (currentHandsDetectedByLeap.Count != trackedHands.Count)
319+
if (CurrentHandsDetectedByLeap.Count != trackedHands.Count)
320320
{
321321
UpdateLeapTrackedHands(leftAttachmentHand.isTracked, rightAttachmentHand.isTracked);
322322
}

0 commit comments

Comments
 (0)