Ejemplo n.º 1
0
        public void SetGrabPoseEditor(Hand hand)
        {
            PoseData pose = new PoseData();

            var handParent = hand.transform.parent;
            var handCopy   = Instantiate(hand, hand.transform.position, hand.transform.rotation);

            handCopy.name                       = "HAND COPY DELETE";
            editorHand                          = handCopy;
            handCopy.transform.parent           = transform;
            handCopy.transform.localPosition    = pose.handOffset;
            handCopy.transform.localEulerAngles = pose.rotationOffset;
            handCopy.transform.parent           = handParent;
            handCopy.editorAutoGrab             = true;

            if (hand.left)
            {
                if (leftPoseSet)
                {
                    pose = leftPose;
                }
                else
                {
                    return;
                }
            }
            else
            {
                if (rightPoseSet)
                {
                    pose = rightPose;
                }
                else
                {
                    return;
                }
            }

            handCopy.transform.localPosition    = pose.handOffset;
            handCopy.transform.localEulerAngles = pose.rotationOffset;

            int i = -1;

            void AssignChildrenPose(Transform obj)
            {
                i++;
                obj.localPosition = pose.posePositions[i];
                obj.localRotation = pose.poseRotations[i];
                for (int j = 0; j < obj.childCount; j++)
                {
                    AssignChildrenPose(obj.GetChild(j));
                }
            }

            if (pose.posePositions.Length > 0)
            {
                foreach (var finger in handCopy.fingers)
                {
                    AssignChildrenPose(finger.transform);
                }
            }
        }