public BoneInfoChain(Transform root) { Transform boneInfoTransform = root; IKFKBlend ikfkBlend = boneInfoTransform.GetComponent <IKFKBlend>(); if (ikfkBlend != null) { _boneInfos.Add(new BoneInfo(boneInfoTransform, ikfkBlend.FK)); } while (boneInfoTransform.childCount == 1 && boneInfoTransform.GetComponent <IKFKBlend>() != null && boneInfoTransform.GetComponent <IKFKBlend>().Handle == null) { //Debug.Log("adding "+ boneInfoTransform.name +" " +count); boneInfoTransform = boneInfoTransform.GetChild(0); ikfkBlend = boneInfoTransform.GetComponent <IKFKBlend>(); if (ikfkBlend != null) { _boneInfos.Add(new BoneInfo(boneInfoTransform, ikfkBlend.FK)); } else { break; } } // Set End Effector ikfkBlend = boneInfoTransform.GetComponent <IKFKBlend>(); if (ikfkBlend != null && ikfkBlend.Handle != null) { Effector = ikfkBlend.Handle; ikControl = Effector.GetComponent <IKControl>(); ik = ikControl.IKFK; EffectorPos = Effector.position; } else { // multi children if (boneInfoTransform.childCount > 1) { foreach (Transform child in boneInfoTransform) { if (ikfkBlend == null && child.GetComponent <IKFKBlend>() == null) { ; } else { _childBoneChains.Add(new BoneInfoChain(child)); } } } } }
public void TraverseHierarchy(Transform root) { Control globalControl = root.transform.GetComponent <Control>(); _Controls.Add(globalControl); foreach (Transform child in root) { GameObject Go = child.gameObject; Control control = Go.transform.GetComponent <Control>(); _Controls.Add(control); Bone bone = Go.transform.GetComponent <Bone>(); _Bones.Add(bone); ParentControl newParentCtrl = Go.transform.GetComponent <ParentControl>(); if (newParentCtrl) { _ParentControls.Add(newParentCtrl); } IKControl newIKCtrl = Go.transform.GetComponent <IKControl>(); if (newIKCtrl) { _Ikhandles.Add(newIKCtrl); } SplineControl splineCtrl = Go.transform.GetComponent <SplineControl>(); if (splineCtrl) { _SplineControls.Add(splineCtrl); } IKFKBlend ikfkBlend = Go.transform.GetComponent <IKFKBlend>(); if (ikfkBlend) { _IKFKBlends.Add(ikfkBlend); } DrivenKey newDrivenKey = Go.transform.GetComponent <DrivenKey>(); if (newDrivenKey) { _DrivenKeys.Add(newDrivenKey); } TraverseHierarchy(child); } }