public override void OnInspectorGUI() { serializedObject.Update(); EditorGUILayout.Space(); Inspector.AddContent(fixTransforms); // Editing References if (BipedReferencesInspector.AddModifiedInspector(references)) { if (!Application.isPlaying) { Warning.logged = false; BipedReferences.CheckSetupError(script.references); BipedReferences.CheckSetupWarning(script.references); script.InitiateBipedIK(); } } // Editing Solvers BipedIKSolversInspector.AddInspector(solvers, solversProps, solverContents); EditorGUILayout.Space(); serializedObject.ApplyModifiedProperties(); }
// Checks the biped references for errors private bool CheckError(BipedReferences references, IKSolverFullBodyBiped solver, Transform context, bool log) { // All the errors common to all bipeds if (!BipedReferences.CheckSetupError(script.references, log)) { if (log) { Warning.Log("Invalid references, can't initiate the solver.", context, true); } return(false); } // All the errors specific to FBBIK if (references.spine.Length == 0) { if (log) { Warning.Log("Biped has no spine bones, can't initiate the solver.", context, true); } return(false); } if (solver.rootNode == null) { if (log) { Warning.Log("Root Node bone is null, can't initiate the solver.", context, true); } return(false); } 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) { if (log) { Warning.Log("The Root Node has to be one of the bones in the Spine or the Pelvis, can't initiate the solver.", context, true); } } } return(true); }
protected override void InitiateSolver() { if (!BipedReferences.CheckSetupError(this.references, Application.isPlaying)) { 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++) { IKSolverLimb iKSolverLimb = limbs[i]; iKSolverLimb.Initiate(base.transform); } this.solvers.pelvis.Initiate(this.references.pelvis); }
/* * Initiates the %IK solver * */ protected override void InitiateSolver() { if (!BipedReferences.CheckSetupError(references, Application.isPlaying)) { 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); }
private bool ReferencesValid(bool log) { return(BipedReferences.CheckSetupError(script.references, log)); }
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.")); // Caching Solver Contents leftFootContent = IKSolverLimbInspector.FindContent(solversProps[0]); rightFootContent = IKSolverLimbInspector.FindContent(solversProps[1]); leftHandContent = IKSolverLimbInspector.FindContent(solversProps[2]); rightHandContent = IKSolverLimbInspector.FindContent(solversProps[3]); spineContent = IKSolverHeuristicInspector.FindContent(solversProps[4]); aimContent = IKSolverAimInspector.FindContent(solversProps[5]); lookAtContent = IKSolverLookAtInspector.FindContent(solversProps[6]); pelvisContent = ConstraintsInspector.FindContent(solversProps[7]); solverContents = new SerializedContent[8][] { leftFootContent, rightFootContent, leftHandContent, rightHandContent, spineContent, aimContent, lookAtContent, pelvisContent }; // 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; BipedReferences.CheckSetupError(script.references); BipedReferences.CheckSetupWarning(script.references); } }