Improved hand tracking option selection
This commit is contained in:
parent
998219ff07
commit
e27a8dea2d
@ -74,11 +74,15 @@ namespace Passer.Humanoid {
|
||||
#if UNITY_ANDROID && hOCHAND
|
||||
if (tracker.oculusHandTracking)
|
||||
handSkeleton = OculusHandSkeleton.Get(unityXR.transform, handTarget.isLeft);
|
||||
else
|
||||
#endif
|
||||
#if hVIVEHAND
|
||||
if (tracker.viveHandTracking)
|
||||
handSkeleton = ViveHandSkeleton.Get(unityXR.transform, handTarget.isLeft);
|
||||
else
|
||||
#endif
|
||||
handSkeleton = UnityXRHandSkeleton.Get(unityXR.transform, handTarget.isLeft);
|
||||
|
||||
}
|
||||
|
||||
#endregion Init
|
||||
|
@ -20,6 +20,33 @@ namespace Passer.Tracking {
|
||||
|
||||
protected XRNode xrNode;
|
||||
|
||||
#region Manage
|
||||
|
||||
public static UnityXRHandSkeleton Find(Transform trackerTransform, bool isLeft) {
|
||||
UnityXRHandSkeleton[] handSkeletons = trackerTransform.GetComponentsInChildren<UnityXRHandSkeleton>();
|
||||
foreach (UnityXRHandSkeleton handSkeleton in handSkeletons) {
|
||||
if (handSkeleton.isLeft == isLeft)
|
||||
return handSkeleton;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static UnityXRHandSkeleton Get(Transform trackerTransform, bool isLeft) {
|
||||
UnityXRHandSkeleton handSkeleton = Find(trackerTransform, isLeft);
|
||||
if (handSkeleton == null) {
|
||||
GameObject skeletonObj = new GameObject(isLeft ? "Left Hand Skeleton" : "Right Hand Skeleton");
|
||||
skeletonObj.transform.parent = trackerTransform;
|
||||
skeletonObj.transform.localPosition = Vector3.zero;
|
||||
skeletonObj.transform.localRotation = Quaternion.identity;
|
||||
|
||||
handSkeleton = skeletonObj.AddComponent<UnityXRHandSkeleton>();
|
||||
handSkeleton.isLeft = isLeft;
|
||||
}
|
||||
return handSkeleton;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Init
|
||||
|
||||
protected override void Start() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user