using UnityEngine; namespace UDE_HAND_INTERACTION { [RequireComponent(typeof(DollHand))] public class VirtualHand : MonoBehaviour { [SerializeField] private DollHand Doll; [SerializeField] //[UnityEngine.Serialization.FormerlySerializedAs("_handGrabPoint")] private HandGrabPose _handGrabPose; public Transform TipPos; protected virtual void Reset() { Doll = this.GetComponent(); _handGrabPose = this.GetComponentInParent(); } protected virtual void OnValidate() { if (Doll == null) { return; } if (_handGrabPose == null) { HandGrabPose point = this.GetComponentInParent(); if (point != null) { SetPose(point); } } else if (_handGrabPose != null) { SetPose(_handGrabPose); } } protected virtual void Start() { this.AssertField(Doll, nameof(Doll)); } public void SetPose(HandGrabPose handGrabPose) { HandPose userPose = handGrabPose.HandPose; if (userPose == null) { return; } Doll.SetJointRotations(userPose.JointRotations); SetRootPose(handGrabPose.RelativePose, handGrabPose.RelativeTo); } public void SetPose(HandPose userPose, Pose rootPose) { Doll.SetJointRotations(userPose.JointRotations); Doll.SetRootPose(rootPose); } public void SetRootPose(Pose rootPose, Transform relativeTo) { Pose pose = rootPose; if (relativeTo != null) { pose = PoseManager.GlobalPoseScaled(relativeTo, rootPose); } Doll.SetRootPose(pose); } } }