Skip to content

Commit dd393ba

Browse files
committed
back compat fixes
1 parent e497663 commit dd393ba

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

Assets/MRTK/Core/Definitions/Devices/MixedRealityHandTrackingProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using Microsoft.MixedReality.Toolkit.Utilities;
5+
using System;
56
using UnityEngine;
67

78
namespace Microsoft.MixedReality.Toolkit.Input
@@ -62,6 +63,7 @@ public class MixedRealityHandTrackingProfile : BaseMixedRealityProfile
6263
/// <summary>
6364
/// The hand mesh prefab to use to render the hand
6465
/// </summary>
66+
[Obsolete("The GameObject which generates the system handmesh is now created at runtime. This prefab is not used")]
6567
public GameObject HandMeshPrefab => handMeshPrefab;
6668

6769
/// <summary>

Assets/MRTK/Core/Providers/Hands/BaseHandVisualizer.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -254,16 +254,27 @@ protected virtual void UpdateHandMesh()
254254

255255
IMixedRealityInputSystem inputSystem = CoreServices.InputSystem;
256256
MixedRealityHandTrackingProfile handTrackingProfile = inputSystem?.InputSystemProfile != null ? inputSystem.InputSystemProfile.HandTrackingProfile : null;
257-
if (newMesh &&
258-
handTrackingProfile != null &&
259-
handTrackingProfile.SystemHandMeshMaterial != null)
257+
if (newMesh && handTrackingProfile != null)
260258
{
261259
// Create the hand mesh in the scene and assign the proper material to it
262-
handMeshFilter = new GameObject("System Hand Mesh").EnsureComponent<MeshFilter>();
263-
handMeshFilter.EnsureComponent<MeshRenderer>().material = CoreServices.InputSystem.InputSystemProfile.HandTrackingProfile.SystemHandMeshMaterial;
264-
265-
lastHandMeshVerticesCount = handMeshFilter.mesh.vertices.Length;
266-
handMeshFilter.transform.parent = transform;
260+
if(handTrackingProfile.SystemHandMeshMaterial.IsNotNull())
261+
{
262+
handMeshFilter = new GameObject("System Hand Mesh").EnsureComponent<MeshFilter>();
263+
handMeshFilter.EnsureComponent<MeshRenderer>().material = handTrackingProfile.SystemHandMeshMaterial;
264+
}
265+
#pragma warning disable 0618
266+
else if (handTrackingProfile.HandMeshPrefab.IsNotNull())
267+
{
268+
handMeshFilter = Instantiate(handTrackingProfile.HandMeshPrefab).GetComponent<MeshFilter>();
269+
}
270+
#pragma warning restore 0618
271+
272+
// Initialize the hand mesh if we generated it successfully
273+
if (handMeshFilter != null)
274+
{
275+
lastHandMeshVerticesCount = handMeshFilter.mesh.vertices.Length;
276+
handMeshFilter.transform.parent = transform;
277+
}
267278
}
268279

269280
if (handMeshFilter != null)
@@ -300,7 +311,7 @@ protected virtual void UpdateHandMesh()
300311
mesh.RecalculateBounds();
301312
}
302313

303-
handMeshFilter.transform.SetPositionAndRotation(eventData.InputData.position, eventData.InputData.rotation);
314+
handMeshFilter.transform.SetPositionAndRotation(lastHandMeshInfo.position, lastHandMeshInfo.rotation);
304315
}
305316
}
306317
}

0 commit comments

Comments
 (0)