/* * Initiates the %IK solver * */ protected override void InitiateSolver() { string message = ""; if (BipedReferences.SetupError(references, ref message)) { Warning.Log(message, references.root, false); return; } solvers.AssignReferences(references); // Initiating solvers if (solvers.spine.bones.Length > 1) { solvers.spine.Initiate(transform); } solvers.lookAt.Initiate(transform); solvers.aim.Initiate(transform); foreach (IKSolverLimb limb in solvers.limbs) { limb.Initiate(transform); } // Initiating constraints solvers.pelvis.Initiate(references.pelvis); }
public bool ReferencesError(ref string errorMessage) { if (BipedReferences.SetupError(this.references, ref errorMessage)) { return(true); } if (this.references.spine.Length == 0) { errorMessage = "References has no spine bones assigned, can not initiate the solver."; return(true); } if (this.solver.rootNode == null) { errorMessage = "Root Node bone is null, can not initiate the solver."; return(true); } if (this.solver.rootNode != this.references.pelvis) { bool flag = false; for (int i = 0; i < this.references.spine.Length; i++) { if (this.solver.rootNode == this.references.spine[i]) { flag = true; break; } } if (!flag) { errorMessage = "The Root Node has to be one of the bones in the Spine or the Pelvis, can not initiate the solver."; return(true); } } return(false); }
/// <summary> /// Checks the biped references for errors. Returns true if error found. /// </summary> public bool ReferencesError(ref string errorMessage) { // All the errors common to all bipeds if (BipedReferences.SetupError(references, ref errorMessage)) { return(true); } // All the errors specific to FBBIK if (references.spine.Length == 0) { errorMessage = "References has no spine bones assigned, can not initiate the solver."; return(true); } if (solver.rootNode == null) { errorMessage = "Root Node bone is null, can not initiate the solver."; return(true); } if (solver.rootNode != references.pelvis) { bool inSpine = false; for (int i = 0; i < references.spine.Length; i++) { if (solver.rootNode == references.spine[i]) { inSpine = true; break; } } if (!inSpine) { errorMessage = "The Root Node has to be one of the bones in the Spine or the Pelvis, can not initiate the solver."; return(true); } } return(false); }
public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); Inspector.AddContent(fixTransforms); string message = string.Empty; // Editing References if (BipedReferencesInspector.AddModifiedInspector(references)) { if (!Application.isPlaying) { Warning.logged = false; if (!BipedReferences.SetupError(script.references, ref message)) { script.InitiateBipedIK(); } } } if (BipedReferences.SetupError(script.references, ref message)) { // Warning box AddWarningBox(message); Warning.Log(message, script.transform, false); } else { // Editing Solvers BipedIKSolversInspector.AddInspector(solvers, solversProps); } EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
protected override void InitiateSolver() { string empty = string.Empty; if (BipedReferences.SetupError(this.references, ref empty)) { Warning.Log(empty, this.references.root, false); return; } this.solvers.AssignReferences(this.references); if (this.solvers.spine.bones.Length > 1) { this.solvers.spine.Initiate(base.transform); } this.solvers.lookAt.Initiate(base.transform); this.solvers.aim.Initiate(base.transform); foreach (IKSolverLimb iksolverLimb in this.solvers.limbs) { iksolverLimb.Initiate(base.transform); } this.solvers.pelvis.Initiate(this.references.pelvis); }
protected override void InitiateSolver() { string message = ""; if (BipedReferences.SetupError(this.references, ref message)) { Warning.Log(message, this.references.root, false); return; } this.solvers.AssignReferences(this.references); if (this.solvers.spine.bones.Length > 1) { this.solvers.spine.Initiate(base.transform); } this.solvers.lookAt.Initiate(base.transform); this.solvers.aim.Initiate(base.transform); IKSolverLimb[] limbs = this.solvers.limbs; for (int i = 0; i < limbs.Length; i++) { limbs[i].Initiate(base.transform); } this.solvers.pelvis.Initiate(this.references.pelvis); }
public void OnEnable() { if (serializedObject == null) { return; } // Store the MonoScript for changing script execution order if (!Application.isPlaying) { MonoScript monoScript = MonoScript.FromMonoBehaviour(script); // Changing the script execution order to make sure BipedIK always executes after any other script except FullBodyBipedIK int executionOrder = MonoImporter.GetExecutionOrder(monoScript); if (executionOrder != 9998) { MonoImporter.SetExecutionOrder(monoScript, 9998); } } references = serializedObject.FindProperty("references"); solvers = serializedObject.FindProperty("solvers"); solversProps = BipedIKSolversInspector.FindProperties(solvers); fixTransforms = new SerializedContent(serializedObject.FindProperty("fixTransforms"), new GUIContent("Fix Transforms", "If true, will fix all the Transforms used by the solver to their initial state in each Update. This prevents potential problems with unanimated bones and animator culling with a small cost of performance.")); // Automatically detecting references if (!Application.isPlaying) { if (script.references.isEmpty) { BipedReferences.AutoDetectReferences(ref script.references, script.transform, new BipedReferences.AutoDetectParams(false, true)); references.isExpanded = true; solvers.isExpanded = false; for (int i = 0; i < solversProps.Length; i++) { solversProps[i].isExpanded = false; } // Setting default values and initiating script.InitiateBipedIK(); script.SetToDefaults(); EditorUtility.SetDirty(script); } else { script.InitiateBipedIK(); } Warning.logged = false; string message = string.Empty; if (Application.isPlaying) { if (BipedReferences.SetupError(script.references, ref message) || BipedReferences.SetupWarning(script.references, ref message)) { Warning.Log(message, script.references.root, false); } } } }