public void SetupTargetModel(Animator targetAnimator) { var dummyAnimator = _refs.dummy; // すべてのスキンメッシュの updateWhnOfscreen を true に foreach (var renderer in targetAnimator.GetComponentsInChildren <SkinnedMeshRenderer> (true)) { renderer.updateWhenOffscreen = true; } // キャリブレーション後処理 var vrikRootController = dummyVrik.GetComponent <VRIKRootController> (); if (vrikRootController != null) { vrikRootController.enabled = true; } // ダミーとターゲットのスケール合わせる if (enableScaleAdjust) { var scale = this.dummyAnimator.GetBoneTransform(HumanBodyBones.Head).position.y / targetAnimator.GetBoneTransform(HumanBodyBones.Head).position.y; targetAnimator.transform.localScale = Vector3.one * scale; } }
virtual protected void OnGUI() { GUILayout.Label("Welcome To The FinalIK hand poser for VRInteraction items", EditorStyles.boldLabel); EditorGUILayout.HelpBox("Reference the VRIK component of the target character you want to set hand poses for, then reference " + "the item you want the hand pose for.", MessageType.Info); var oldVRIK = _vrIK; _vrIK = (VRIK)EditorGUILayout.ObjectField("VRIK", _vrIK, typeof(VRIK), true); if (oldVRIK != null && _vrIK != oldVRIK) { ResetHands(oldVRIK); _handPoseController = null; } _item = (VRInteractableItem)EditorGUILayout.ObjectField("VR Interactable Item", _item, typeof(VRInteractableItem), true); if (_vrIK == null || _item == null || _item.item == null || IsPrefab(_item.item.gameObject)) { return; } if (_handPoseController == null) { _handPoseController = _vrIK.GetComponent <HandPoseController>(); if (_handPoseController == null) { _handPoseController = _vrIK.gameObject.AddComponent <HandPoseController>(); } //Set pose name to default if set foreach (Transform pose in _handPoseController.poses) { if (pose.name == _item.leftHandIKPoseName) { _leftPoseName = pose.name; } if (pose.name == _item.rightHandIkPoseName) { _rightPoseName = pose.name; } } } GUILayout.BeginHorizontal(); switch (_hand) { case Hand.LEFT: GUILayout.Box("Left Hand", GUILayout.ExpandWidth(true)); if (GUILayout.Button("Right Hand")) { _hand = Hand.RIGHT; } break; case Hand.RIGHT: if (GUILayout.Button("Left Hand")) { _hand = Hand.LEFT; } GUILayout.Box("Right Hand", GUILayout.ExpandWidth(true)); break; } GUILayout.EndHorizontal(); Transform handTrans = _hand == Hand.LEFT ? _vrIK.references.leftHand : _vrIK.references.rightHand; if (handTrans == null) { EditorGUILayout.HelpBox("VRIK left or right hand reference is null", MessageType.Error); return; } DefaultPoses(); bool changed = ShowExistingPoses(); if (changed) { if (_hand == Hand.LEFT && _leftPoseIndex < _handPoseController.poses.Count && _handPoseController.poses[_leftPoseIndex] != null) { _leftPoseName = _handPoseController.poses[_leftPoseIndex].name; } else if (_rightPoseIndex < _handPoseController.poses.Count && _handPoseController.poses[_rightPoseIndex] != null) { _rightPoseName = _handPoseController.poses[_rightPoseIndex].name; } } if (_hand == Hand.LEFT) { _leftPoseName = EditorGUILayout.TextField("Pose Name", _leftPoseName); } else { _rightPoseName = EditorGUILayout.TextField("Pose Name", _rightPoseName); } if (GUILayout.Button("Move Hand To Item")) { MoveToItem(); } if (GUILayout.Button("Reset Hand")) { ResetHands(_vrIK); } EditorGUI.BeginDisabledGroup((_hand == Hand.LEFT ? _vrIK.references.leftHand : _vrIK.references.rightHand) == null || string.IsNullOrEmpty(_hand == Hand.LEFT ? _leftPoseName : _rightPoseName)); if (GUILayout.Button("Select Hand Object")) { Selection.activeGameObject = _hand == Hand.LEFT ? _vrIK.references.leftHand.gameObject : _vrIK.references.rightHand.gameObject; } if (GUILayout.Button("Save Pose")) { SaveHand(); } EditorGUI.EndDisabledGroup(); }