GameObject rig_legRF = new GameObject();
rig_legRF.name = "rig_legRF";
Rig rig_legRF_RIG= rig_legRF.AddComponent<Rig>();
rig_legRF.GetComponent<Rig>().weight = 1;
GameObject TwoIK_legRF = new GameObject();
TwoIK_legRF.name = "TwoIK_legRF";
TwoIK_legRF.transform.SetParent(rig_legRF.transform);
TwoBoneIKConstraint rig_legRF_2IK = TwoIK_legRF.AddComponent<TwoBoneIKConstraint>();
// TwoBoneIKConstraint rig_legRF_2IK = new TwoBoneIKConstraint();
rig_legRF_2IK.data.root = joint_rf1.transform;
rig_legRF_2IK.data.mid = joint_rf2.transform;
rig_legRF_2IK.data.tip = joint_rf3.transform;
rig_legRF_2IK.data.hint = hint_legRF.transform;
rig_legRF_2IK.data.target = Targets_legRF.transform;
rig_legRF_2IK.data.targetPositionWeight = 1;
rig_legRF_2IK.data.targetRotationWeight = 1;
rig_legRF_2IK.data.hintWeight = 1;
// TwoIK_legRF.AddComponent<TwoBoneIKConstraint>(rig_legRF_2IK);
rig_legRF.transform.SetParent(obj1.transform);
RigBuilder RIGBuilder_legRF = obj1.AddComponent<RigBuilder>();
RIGBuilder_legRF.layers.Add(new RigBuilder.RigLayer(rig_legRF_RIG,true));
就是添加 了一个 TwoBoneIKConstraint 。 如果我在UI 上手动添加的话是可用的。 但是用脚本添加就不行
rig_legRF.name = "rig_legRF";
Rig rig_legRF_RIG= rig_legRF.AddComponent<Rig>();
rig_legRF.GetComponent<Rig>().weight = 1;
GameObject TwoIK_legRF = new GameObject();
TwoIK_legRF.name = "TwoIK_legRF";
TwoIK_legRF.transform.SetParent(rig_legRF.transform);
TwoBoneIKConstraint rig_legRF_2IK = TwoIK_legRF.AddComponent<TwoBoneIKConstraint>();
// TwoBoneIKConstraint rig_legRF_2IK = new TwoBoneIKConstraint();
rig_legRF_2IK.data.root = joint_rf1.transform;
rig_legRF_2IK.data.mid = joint_rf2.transform;
rig_legRF_2IK.data.tip = joint_rf3.transform;
rig_legRF_2IK.data.hint = hint_legRF.transform;
rig_legRF_2IK.data.target = Targets_legRF.transform;
rig_legRF_2IK.data.targetPositionWeight = 1;
rig_legRF_2IK.data.targetRotationWeight = 1;
rig_legRF_2IK.data.hintWeight = 1;
// TwoIK_legRF.AddComponent<TwoBoneIKConstraint>(rig_legRF_2IK);
rig_legRF.transform.SetParent(obj1.transform);
RigBuilder RIGBuilder_legRF = obj1.AddComponent<RigBuilder>();
RIGBuilder_legRF.layers.Add(new RigBuilder.RigLayer(rig_legRF_RIG,true));
就是添加 了一个 TwoBoneIKConstraint 。 如果我在UI 上手动添加的话是可用的。 但是用脚本添加就不行