public override void OnInspectorGUI() { var ik = target as IKCCD; ik.Enable = EditorGUILayout.Toggle("Enabled", ik.Enable); ik.Iteration = EditorGUILayout.IntField("Iteration", ik.Iteration); EditorGUILayout.Space(); if (GUILayout.Button("Set Initial")) { for (var i = 0; i < ik.Bones.Length; i++) { ik.InitialRotation[i] = ik.Bones[i].transform.localRotation; } } var bone = EditorGUILayout.ObjectField("Start Bone", ik.StartBone, typeof(Bone), true) as Bone; if (bone != ik.StartBone) { ik.StartBone = bone; InitBones(); } bone = EditorGUILayout.ObjectField("End Bone", ik.EndBone, typeof(Bone), true) as Bone; if (bone != ik.EndBone) { ik.EndBone = bone; InitBones(); } EditorGUILayout.Space(); showBones = EditorUtility.DrawFoldList("Bones", showBones, ik.Bones.Length, (i) => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(ik.Bones[i], typeof(Bone), true); ik.Weights[i] = EditorGUILayout.FloatField("Weight", ik.Weights[i]); EditorGUILayout.EndHorizontal(); }); if (GUILayout.Button("Start")) { iterator = IKCCD.InverseKinematicsIterate(ik.Bones, ik.transform.position, ik.Iteration); it = 0; } if (GUILayout.Button("Next")) { iterator.MoveNext(); } }
public override void OnInspectorGUI() { var ik = target as IKCCD; ik.Iteration = EditorGUILayout.IntField("Iteration", ik.Iteration); ik.StartOffset = Quaternion.Euler(EditorGUILayout.Vector3Field("Start Offset", ik.StartOffset.eulerAngles)); EditorGUILayout.Space(); var bone = EditorGUILayout.ObjectField("Start Bone", ik.StartBone, typeof(Bone), true) as Bone; if (bone != ik.StartBone) { ik.StartBone = bone; InitBones(); } bone = EditorGUILayout.ObjectField("End Bone", ik.EndBone, typeof(Bone), true) as Bone; if (bone != ik.EndBone) { ik.EndBone = bone; InitBones(); } EditorGUILayout.Space(); showBones = EditorUtility.DrawFoldList("Bones", showBones, ik.Bones.Length, (i) => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.ObjectField(ik.Bones[i], typeof(Bone), true); ik.Weights[i] = EditorGUILayout.FloatField("Weight", ik.Weights[i]); EditorGUILayout.EndHorizontal(); }); if (GUILayout.Button("Start")) { iterator = IKCCD.InverseKinematicsIterate(ik.Bones, ik.transform.position, ik.Iteration); it = 0; } if (GUILayout.Button("Next")) { iterator.MoveNext(); } SceneView.RepaintAll(); }