Skip to content

Commit 9d356c4

Browse files
committed
Add proper null checking
1 parent 32373fc commit 9d356c4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XR2018/WindowsMixedRealityArticulatedHand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,14 @@ private void UpdateHandData(InteractionSourceState interactionSourceState)
227227
HandPose handPose = sourceState.TryGetHandPose();
228228

229229
#if WINDOWS_UWP
230-
if (CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.EnableHandMeshVisualization)
230+
MixedRealityHandTrackingProfile handTrackingProfile = null;
231+
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
232+
if (inputSystemProfile != null)
233+
{
234+
handTrackingProfile = inputSystemProfile.HandTrackingProfile;
235+
}
236+
237+
if (handTrackingProfile != null && handTrackingProfile.EnableHandMeshVisualization)
231238
{
232239
// Accessing the hand mesh data involves copying quite a bit of data, so only do it if application requests it.
233240
if (handMeshObserver == null && !hasRequestedHandMeshObserver)

Assets/MixedRealityToolkit.Providers/WindowsMixedReality/XRSDK/Controllers/WindowsMixedRealityXRSDKArticulatedHand.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ private void UpdateHandData(InputDevice inputDevice)
158158
}
159159

160160
#if WINDOWS_UWP
161-
if (!CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.EnableHandMeshVisualization)
161+
MixedRealityHandTrackingProfile handTrackingProfile = null;
162+
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
163+
if (inputSystemProfile != null)
164+
{
165+
handTrackingProfile = inputSystemProfile.HandTrackingProfile;
166+
}
167+
168+
if (handTrackingProfile == null || !handTrackingProfile.EnableHandMeshVisualization)
162169
{
163170
// if hand mesh visualization is disabled make sure to destroy our hand mesh observer if it has already been created
164171
if (handMeshObserver != null)

0 commit comments

Comments
 (0)