diff --git a/Assets/SteamVR/Input/Editor/SteamVR_Skeleton_PoserEditor.cs b/Assets/SteamVR/Input/Editor/SteamVR_Skeleton_PoserEditor.cs index 68793f8..d7829ec 100644 --- a/Assets/SteamVR/Input/Editor/SteamVR_Skeleton_PoserEditor.cs +++ b/Assets/SteamVR/Input/Editor/SteamVR_Skeleton_PoserEditor.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -using UnityEditor; +using UnityEditor; using UnityEngine; namespace Valve.VR @@ -405,8 +400,15 @@ namespace Valve.VR dest.rightHand.rotation = source.rightHand.rotation; for (int boneIndex = 0; boneIndex < boneNum; boneIndex++) { - dest.rightHand.bonePositions[boneIndex] = source.rightHand.bonePositions[boneIndex]; - dest.rightHand.boneRotations[boneIndex] = source.rightHand.boneRotations[boneIndex]; + if (boneIndex < dest.rightHand.bonePositions.Length && boneIndex < source.rightHand.bonePositions.Length) + { + dest.rightHand.bonePositions[boneIndex] = source.rightHand.bonePositions[boneIndex]; + } + if (boneIndex < dest.rightHand.boneRotations.Length && boneIndex < source.rightHand.boneRotations.Length) + { + dest.rightHand.boneRotations[boneIndex] = source.rightHand.boneRotations[boneIndex]; + } + EditorUtility.DisplayProgressBar("Copying...", "Copying right hand pose", (float)boneIndex / (float)boneNum / 2f); } dest.rightHand.thumbFingerMovementType = source.rightHand.thumbFingerMovementType; @@ -421,8 +423,14 @@ namespace Valve.VR dest.leftHand.rotation = source.leftHand.rotation; for (int boneIndex = 0; boneIndex < boneNum; boneIndex++) { - dest.leftHand.bonePositions[boneIndex] = source.leftHand.bonePositions[boneIndex]; - dest.leftHand.boneRotations[boneIndex] = source.leftHand.boneRotations[boneIndex]; + if (boneIndex < dest.rightHand.bonePositions.Length && boneIndex < source.rightHand.bonePositions.Length) + { + dest.rightHand.bonePositions[boneIndex] = source.rightHand.bonePositions[boneIndex]; + } + if (boneIndex < dest.rightHand.boneRotations.Length && boneIndex < source.rightHand.boneRotations.Length) + { + dest.rightHand.boneRotations[boneIndex] = source.rightHand.boneRotations[boneIndex]; + } EditorUtility.DisplayProgressBar("Copying...", "Copying left hand pose", (float)boneIndex / (float)boneNum / 2f); } dest.leftHand.thumbFingerMovementType = source.leftHand.thumbFingerMovementType;