public static void UpdateIK(Bone2D bone, string undoName) { List <Bone2D> boneList = new List <Bone2D>(25); List <Ik2D> ikList = new List <Ik2D>(25); BuildIkList(bone, boneList, ikList); for (int i = 0; i < ikList.Count; i++) { Ik2D l_ik2D = ikList[i]; if (l_ik2D && l_ik2D.isActiveAndEnabled) { for (int j = 0; j < l_ik2D.solver.solverPoses.Count; j++) { IkSolver2D.SolverPose pose = l_ik2D.solver.solverPoses [j]; if (pose.bone) { Undo.RecordObject(pose.bone.transform, undoName); } } l_ik2D.solver.RestoreDefaultPoses(); l_ik2D.UpdateIK(); } } }
static void UpdateIkList(List <Ik2D> ikList, string undoName, bool recordObject) { for (int i = 0; i < ikList.Count; i++) { Ik2D l_ik2D = ikList[i]; if (l_ik2D && l_ik2D.isActiveAndEnabled) { if (!string.IsNullOrEmpty(undoName)) { for (int j = 0; j < l_ik2D.solver.solverPoses.Count; j++) { IkSolver2D.SolverPose pose = l_ik2D.solver.solverPoses [j]; if (pose.bone) { if (recordObject) { Undo.RecordObject(pose.bone.transform, undoName); } else { Undo.RegisterCompleteObjectUndo(pose.bone.transform, undoName); } } } } if (!string.IsNullOrEmpty(undoName) && l_ik2D.orientChild && l_ik2D.target && l_ik2D.target.child) { if (recordObject) { Undo.RecordObject(l_ik2D.target.child.transform, undoName); } else { Undo.RegisterCompleteObjectUndo(l_ik2D.target.child.transform, undoName); } } l_ik2D.UpdateIK(); for (int j = 0; j < l_ik2D.solver.solverPoses.Count; j++) { IkSolver2D.SolverPose pose = l_ik2D.solver.solverPoses [j]; if (pose.bone) { BoneUtils.FixLocalEulerHint(pose.bone.transform); } if (l_ik2D.orientChild && l_ik2D.target.child) { BoneUtils.FixLocalEulerHint(l_ik2D.target.child.transform); } } } } }
public void UpdateGroup() { for (int i = 0; i < m_IkComponents.Count; i++) { Ik2D ik = m_IkComponents[i]; if (ik) { ik.enabled = false; ik.UpdateIK(); } } }