protected override void Awake() { base.Awake(); _finger = this.GetComponent <RiggedFinger>(); _typeFinger = _finger.fingerType; if (_typeFinger == Finger.FingerType.TYPE_THUMB) { Debug.LogWarning("Finger type is Thumb : Can't pinch. Script disabled."); this.enabled = false; } }
//Find Fingers and assign RiggedFingers private void findAndAssignRiggedFingers(bool useMetaCarpals) { if (!useMetaCarpals) { RiggedFinger_L_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftIndexProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftMiddleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftRingProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftLittleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightIndexProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightMiddleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightRingProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightLittleProximal).gameObject.AddComponent <RiggedFinger>(); } else { RiggedFinger_L_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftIndexProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftMiddleProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftRingProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftLittleProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightIndexProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightMiddleProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightRingProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightLittleProximal).gameObject.transform.parent.gameObject.AddComponent <RiggedFinger>(); } RiggedFinger_L_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_L_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_L_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_L_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_L_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; RiggedFinger_R_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_R_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_R_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_R_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_R_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; }
/**Finds palm and finds root of each finger by name and assigns RiggedFinger scripts */ private void assignRiggedFingersByName() { List <string> palmStrings = new List <string> { "palm" }; List <string> thumbStrings = new List <string> { "thumb", "tmb" }; List <string> indexStrings = new List <string> { "index", "idx" }; List <string> middleStrings = new List <string> { "middle", "mid" }; List <string> ringStrings = new List <string> { "ring" }; List <string> pinkyStrings = new List <string> { "pinky", "pin" }; //find palm by name //Transform palm = null; Transform thumb = null; Transform index = null; Transform middle = null; Transform ring = null; Transform pinky = null; Transform[] children = transform.GetComponentsInChildren <Transform>(); if (palmStrings.Any(w => transform.name.ToLower().Contains(w))) { base.palm = transform; } else { foreach (Transform t in children) { if (palmStrings.Any(w => t.name.ToLower().Contains(w)) == true) { base.palm = t; } } } if (!palm) { palm = transform; } if (palm) { foreach (Transform t in children) { RiggedFinger preExistingRiggedFinger; preExistingRiggedFinger = t.GetComponent <RiggedFinger>(); string lowercaseName = t.name.ToLower(); if (!preExistingRiggedFinger) { if (thumbStrings.Any(w => lowercaseName.Contains(w)) && t.parent == palm) { thumb = t; RiggedFinger newRiggedFinger = thumb.gameObject.AddComponent <RiggedFinger>(); newRiggedFinger.fingerType = Finger.FingerType.TYPE_THUMB; } if (indexStrings.Any(w => lowercaseName.Contains(w)) && t.parent == palm) { index = t; RiggedFinger newRiggedFinger = index.gameObject.AddComponent <RiggedFinger>(); newRiggedFinger.fingerType = Finger.FingerType.TYPE_INDEX; } if (middleStrings.Any(w => lowercaseName.Contains(w)) && t.parent == palm) { middle = t; RiggedFinger newRiggedFinger = middle.gameObject.AddComponent <RiggedFinger>(); newRiggedFinger.fingerType = Finger.FingerType.TYPE_MIDDLE; } if (ringStrings.Any(w => lowercaseName.Contains(w)) && t.parent == palm) { ring = t; RiggedFinger newRiggedFinger = ring.gameObject.AddComponent <RiggedFinger>(); newRiggedFinger.fingerType = Finger.FingerType.TYPE_RING; } if (pinkyStrings.Any(w => lowercaseName.Contains(w)) && t.parent == palm) { pinky = t; RiggedFinger newRiggedFinger = pinky.gameObject.AddComponent <RiggedFinger>(); newRiggedFinger.fingerType = Finger.FingerType.TYPE_PINKY; } } } } }
void AutoRigByName() { List <string> LeftHandStrings = new List <string> { "left" }; List <string> RightHandStrings = new List <string> { "right" }; //Assigning these here since this component gets added and used at editor time HandPoolToPopulate = GameObject.FindObjectOfType <HandPool>(); Reset(); //Find hands and assigns RiggedHands Transform Hand_L = null; foreach (Transform t in transform) { if (LeftHandStrings.Any(w => t.name.ToLower().Contains(w))) { Hand_L = t; } } if (Hand_L != null) { RiggedHand_L = Hand_L.gameObject.AddComponent <RiggedHand>(); HandTransitionBehavior_L = Hand_L.gameObject.AddComponent <HandEnableDisable>(); RiggedHand_L.Handedness = Chirality.Left; RiggedHand_L.SetEditorLeapPose = false; RiggedHand_L.UseMetaCarpals = UseMetaCarpals; RiggedHand_L.SetupRiggedHand(); RiggedFinger_L_Thumb = (RiggedFinger)RiggedHand_L.fingers[0]; RiggedFinger_L_Index = (RiggedFinger)RiggedHand_L.fingers[1]; RiggedFinger_L_Mid = (RiggedFinger)RiggedHand_L.fingers[2]; RiggedFinger_L_Ring = (RiggedFinger)RiggedHand_L.fingers[3]; RiggedFinger_L_Pinky = (RiggedFinger)RiggedHand_L.fingers[4]; modelFingerPointing_L = RiggedHand_L.modelFingerPointing; modelPalmFacing_L = RiggedHand_L.modelPalmFacing; RiggedHand_L.StoreJointsStartPose(); } Transform Hand_R = null; foreach (Transform t in transform) { if (RightHandStrings.Any(w => t.name.ToLower().Contains(w))) { Hand_R = t; } } if (Hand_R != null) { RiggedHand_R = Hand_R.gameObject.AddComponent <RiggedHand>(); HandTransitionBehavior_R = Hand_R.gameObject.AddComponent <HandEnableDisable>(); RiggedHand_R.Handedness = Chirality.Right; RiggedHand_R.SetEditorLeapPose = false; RiggedHand_R.UseMetaCarpals = UseMetaCarpals; RiggedHand_R.SetupRiggedHand(); RiggedFinger_R_Thumb = (RiggedFinger)RiggedHand_R.fingers[0]; RiggedFinger_R_Index = (RiggedFinger)RiggedHand_R.fingers[1]; RiggedFinger_R_Mid = (RiggedFinger)RiggedHand_R.fingers[2]; RiggedFinger_R_Ring = (RiggedFinger)RiggedHand_R.fingers[3]; RiggedFinger_R_Pinky = (RiggedFinger)RiggedHand_R.fingers[4]; modelFingerPointing_R = RiggedHand_R.modelFingerPointing; modelPalmFacing_R = RiggedHand_R.modelPalmFacing; RiggedHand_R.StoreJointsStartPose(); } //Find palms and assign to RiggedHands //RiggedHand_L.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); //RiggedHand_R.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); if (ModelGroupName == "" || ModelGroupName != null) { ModelGroupName = transform.name; } HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R); }
void AutoRigByName() { List<string> LeftHandStrings = new List<string> { "left", "_l" }; List<string> RightHandStrings = new List<string> { "right", "_r" }; //Assigning these here since this component gets added and used at editor time HandPoolToPopulate = GameObject.FindObjectOfType<HandPool>(); Reset(); //Find hands and assigns RiggedHands Transform Hand_L = null; foreach (Transform t in transform) { if (LeftHandStrings.Any(w => t.name.ToLower().Contains(w))) { Hand_L = t; } } RiggedHand_L = Hand_L.gameObject.AddComponent<RiggedHand>(); HandTransitionBehavior_L = Hand_L.gameObject.AddComponent<HandEnableDisable>(); RiggedHand_L.Handedness = Chirality.Left; RiggedHand_L.SetEditorLeapPose = false; RiggedHand_L.UseMetaCarpals = UseMetaCarpals; Transform Hand_R = null; foreach (Transform t in transform) { if (RightHandStrings.Any(w => t.name.ToLower().Contains(w))) { Hand_R = t; } } RiggedHand_R = Hand_R.gameObject.AddComponent<RiggedHand>(); HandTransitionBehavior_R = Hand_R.gameObject.AddComponent<HandEnableDisable>(); RiggedHand_R.Handedness = Chirality.Right; RiggedHand_R.SetEditorLeapPose = false; RiggedHand_R.UseMetaCarpals = UseMetaCarpals; //Find palms and assign to RiggedHands //RiggedHand_L.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); //RiggedHand_R.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); RiggedHand_L.SetupRiggedHand(); RiggedHand_R.SetupRiggedHand(); if (ModelGroupName == "" || ModelGroupName != null) { ModelGroupName = transform.name; } HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R); RiggedFinger_L_Thumb = (RiggedFinger)RiggedHand_L.fingers[0]; RiggedFinger_L_Index = (RiggedFinger)RiggedHand_L.fingers[1]; RiggedFinger_L_Mid = (RiggedFinger)RiggedHand_L.fingers[2]; RiggedFinger_L_Ring = (RiggedFinger)RiggedHand_L.fingers[3]; RiggedFinger_L_Pinky = (RiggedFinger)RiggedHand_L.fingers[4]; RiggedFinger_R_Thumb = (RiggedFinger)RiggedHand_R.fingers[0]; RiggedFinger_R_Index = (RiggedFinger)RiggedHand_R.fingers[1]; RiggedFinger_R_Mid = (RiggedFinger)RiggedHand_R.fingers[2]; RiggedFinger_R_Ring = (RiggedFinger)RiggedHand_R.fingers[3]; RiggedFinger_R_Pinky = (RiggedFinger)RiggedHand_R.fingers[4]; modelFingerPointing_L = RiggedHand_L.modelFingerPointing; modelPalmFacing_L = RiggedHand_L.modelPalmFacing; modelFingerPointing_R = RiggedHand_R.modelFingerPointing; modelPalmFacing_R = RiggedHand_R.modelPalmFacing; }
void AutoRigMecanim() { //Assigning these here since this component gets added and used at editor time AnimatorForMapping = gameObject.GetComponent<Animator>(); HandPoolToPopulate = GameObject.FindObjectOfType<HandPool>(); Reset(); //Find hands and assign RiggedHands Transform Hand_L = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); if (Hand_L.GetComponent<RiggedHand>()) { RiggedHand_L = Hand_L.GetComponent<RiggedHand>(); } else RiggedHand_L = Hand_L.gameObject.AddComponent<RiggedHand>(); HandTransitionBehavior_L =Hand_L.gameObject.AddComponent<HandDrop>(); RiggedHand_L.Handedness = Chirality.Left; RiggedHand_L.SetEditorLeapPose = false; Transform Hand_R = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); if (Hand_R.GetComponent<RiggedHand>()) { RiggedHand_R = Hand_R.GetComponent<RiggedHand>(); } else RiggedHand_R = Hand_R.gameObject.AddComponent<RiggedHand>(); HandTransitionBehavior_R = Hand_R.gameObject.AddComponent<HandDrop>(); RiggedHand_R.Handedness = Chirality.Right; RiggedHand_R.SetEditorLeapPose = false; //Find palms and assign to RiggedHands RiggedHand_L.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); RiggedHand_R.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); //Find Fingers and assign RiggedFingers RiggedFinger_L_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftThumbProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_L_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_L_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftIndexProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_L_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_L_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftMiddleProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_L_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_L_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftRingProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_L_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_L_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftLittleProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_L_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; RiggedFinger_R_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightThumbProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_R_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_R_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightIndexProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_R_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_R_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightMiddleProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_R_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_R_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightRingProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_R_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_R_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightLittleProximal).gameObject.AddComponent<RiggedFinger>(); RiggedFinger_R_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; RiggedHand_L.AutoRigRiggedHand(RiggedHand_L.palm, RiggedFinger_L_Pinky.transform, RiggedFinger_L_Index.transform); RiggedHand_R.AutoRigRiggedHand(RiggedHand_R.palm, RiggedFinger_R_Pinky.transform, RiggedFinger_R_Index.transform); if (ModelGroupName == "" || ModelGroupName != null) { ModelGroupName = transform.name; } HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R); modelFingerPointing_L = RiggedHand_L.modelFingerPointing; modelPalmFacing_L = RiggedHand_L.modelPalmFacing; modelFingerPointing_R = RiggedHand_R.modelFingerPointing; modelPalmFacing_R = RiggedHand_R.modelPalmFacing; }
private void Awake() { path = new List <Vector3>(); finger = GetComponent <RiggedFinger>(); }
void AutoRigMecanim() { //Assigning these here since this component gets added and used at editor time AnimatorForMapping = gameObject.GetComponent <Animator>(); HandPoolToPopulate = GameObject.FindObjectOfType <HandPool>(); Reset(); //Find hands and assign RiggedHands Transform Hand_L = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); if (Hand_L.GetComponent <RiggedHand>()) { RiggedHand_L = Hand_L.GetComponent <RiggedHand>(); } else { RiggedHand_L = Hand_L.gameObject.AddComponent <RiggedHand>(); } HandTransitionBehavior_L = Hand_L.gameObject.AddComponent <HandDrop>(); RiggedHand_L.Handedness = Chirality.Left; RiggedHand_L.SetEditorLeapPose = false; Transform Hand_R = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); if (Hand_R.GetComponent <RiggedHand>()) { RiggedHand_R = Hand_R.GetComponent <RiggedHand>(); } else { RiggedHand_R = Hand_R.gameObject.AddComponent <RiggedHand>(); } HandTransitionBehavior_R = Hand_R.gameObject.AddComponent <HandDrop>(); RiggedHand_R.Handedness = Chirality.Right; RiggedHand_R.SetEditorLeapPose = false; //Find palms and assign to RiggedHands RiggedHand_L.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftHand); RiggedHand_R.palm = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightHand); //Find Fingers and assign RiggedFingers RiggedFinger_L_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_L_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftIndexProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_L_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftMiddleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_L_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftRingProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_L_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.LeftLittleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_L_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; RiggedFinger_R_Thumb = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightThumbProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Thumb.fingerType = Finger.FingerType.TYPE_THUMB; RiggedFinger_R_Index = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightIndexProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Index.fingerType = Finger.FingerType.TYPE_INDEX; RiggedFinger_R_Mid = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightMiddleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Mid.fingerType = Finger.FingerType.TYPE_MIDDLE; RiggedFinger_R_Ring = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightRingProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Ring.fingerType = Finger.FingerType.TYPE_RING; RiggedFinger_R_Pinky = AnimatorForMapping.GetBoneTransform(HumanBodyBones.RightLittleProximal).gameObject.AddComponent <RiggedFinger>(); RiggedFinger_R_Pinky.fingerType = Finger.FingerType.TYPE_PINKY; RiggedHand_L.AutoRigRiggedHand(RiggedHand_L.palm, RiggedFinger_L_Pinky.transform, RiggedFinger_L_Index.transform); RiggedHand_R.AutoRigRiggedHand(RiggedHand_R.palm, RiggedFinger_R_Pinky.transform, RiggedFinger_R_Index.transform); if (ModelGroupName == "" || ModelGroupName != null) { ModelGroupName = transform.name; } HandPoolToPopulate.AddNewGroup(ModelGroupName, RiggedHand_L, RiggedHand_R); modelFingerPointing_L = RiggedHand_L.modelFingerPointing; modelPalmFacing_L = RiggedHand_L.modelPalmFacing; modelFingerPointing_R = RiggedHand_R.modelFingerPointing; modelPalmFacing_R = RiggedHand_R.modelPalmFacing; }