/* * Returns all solver SeiralizedProperties * */ public static SerializedContent[] FindContent(SerializedProperty prop) { SerializedContent[] c = IKSolverHeuristicInspector.FindContent(prop); Array.Resize(ref c, c.Length + 4); c[c.Length - 4] = new SerializedContent(prop.FindPropertyRelative("transform"), new GUIContent("Aim Transform", "The transform that's you want to be aimed at IKPosition. Needs to be a lineal descendant of the bone hierarchy.")); c[c.Length - 3] = new SerializedContent(prop.FindPropertyRelative("axis"), new GUIContent("Axis", "The local axis of the Transform that you want to be aimed at IKPosition.")); c[c.Length - 2] = new SerializedContent(prop.FindPropertyRelative("clampWeight"), new GUIContent("Clamp Weight", "Clamping rotation of the solver. 0 is free rotation, 1 is completely clamped to transform axis.")); c[c.Length - 1] = new SerializedContent(prop.FindPropertyRelative("clampSmoothing"), new GUIContent("Clamp Smoothing", "Number of sine smoothing iterations applied on clamping to make the clamping point smoother.")); return(c); }
protected override void AddInspector() { // Draw the inspector for IKSolverFABRIK IKSolverHeuristicInspector.AddInspector(solver, !Application.isPlaying, false); // Warning box string message = string.Empty; if (!script.solver.IsValid(ref message)) { AddWarningBox(message); } }
private static void AddSceneChain(FABRIKChain[] chain, Color color, FABRIKChain selected) { foreach (FABRIKChain c in chain) { if (!c.IsValid(null)) { return; } } foreach (FABRIKChain c in chain) { col = GetChainColor(c, color); IKSolverHeuristicInspector.AddScene(c.ik.solver as IKSolverHeuristic, col, selected == c); } }
/* * Draws the scene view helpers for BipedIK.Solvers * */ public static void AddScene(BipedIKSolvers solvers, ref int selected) { // Draw limbs for (int i = 0; i < solvers.limbs.Length; i++) { IKSolverLimbInspector.AddScene(solvers.limbs[i] as IKSolverLimb, GetSolverColor(i), selected == i); } // Draw spine IKSolverHeuristicInspector.AddScene(solvers.spine, GetSolverColor(4), selected == 4); // Draw look at IKSolverLookAtInspector.AddScene(solvers.lookAt, GetSolverColor(5), selected == 5); // Draw aim IKSolverAimInspector.AddScene(solvers.aim, GetSolverColor(6), selected == 6); // Draw constraints ConstraintsInspector.AddScene(solvers.pelvis, GetSolverColor(7), selected == 7); // Selecting solvers if (Application.isPlaying) { for (int i = 0; i < solvers.ikSolvers.Length; i++) { Handles.color = GetSolverColor(i); if (solvers.ikSolvers[i].GetIKPositionWeight() > 0 && selected != i && solvers.ikSolvers[i].initiated) { if (Inspector.DotButton(solvers.ikSolvers[i].GetIKPosition(), Quaternion.identity, GetHandleSize(solvers.ikSolvers[i].GetIKPosition()), GetHandleSize(solvers.ikSolvers[i].GetIKPosition()))) { selected = i; } } } if ((solvers.pelvis.positionWeight > 0 || solvers.pelvis.rotationWeight > 0) && selected != solvers.ikSolvers.Length) { Handles.color = GetSolverColor(7); if (Inspector.DotButton(solvers.pelvis.position, Quaternion.identity, GetHandleSize(solvers.pelvis.position), GetHandleSize(solvers.pelvis.position))) { selected = solvers.ikSolvers.Length; } } } }
/// <summary> /// Draws the custom inspector for IKSolverAim /// </summary> public static void AddInspector(SerializedProperty prop, bool editHierarchy) { IKSolverHeuristicInspector.AddTarget(prop); EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleTarget"), new GUIContent("Pole Target", "If assigned, will automatically set polePosition to the position of this Transform.")); EditorGUILayout.PropertyField(prop.FindPropertyRelative("transform"), new GUIContent("Aim Transform", "The transform that's you want to be aimed at IKPosition. Needs to be a lineal descendant of the bone hierarchy.")); EditorGUILayout.PropertyField(prop.FindPropertyRelative("axis"), new GUIContent("Axis", "The local axis of the Transform that you want to be aimed at IKPosition.")); EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleAxis"), new GUIContent("Pole Axis", "Keeps that axis of the Aim Transform directed at the polePosition.")); EditorGUILayout.Space(); IKSolverHeuristicInspector.AddIKPositionWeight(prop); EditorGUILayout.PropertyField(prop.FindPropertyRelative("poleWeight"), new GUIContent("Pole Weight", "The weight of the Pole.")); IKSolverHeuristicInspector.AddProps(prop); EditorGUILayout.PropertyField(prop.FindPropertyRelative("clampWeight"), new GUIContent("Clamp Weight", "Clamping rotation of the solver. 0 is free rotation, 1 is completely clamped to transform axis.")); EditorGUILayout.PropertyField(prop.FindPropertyRelative("clampSmoothing"), new GUIContent("Clamp Smoothing", "Number of sine smoothing iterations applied on clamping to make the clamping point smoother.")); IKSolverHeuristicInspector.AddBones(prop, editHierarchy, true); }
/* * Draws the custom inspector for BipedIK.Solvers * */ public static void AddInspector(SerializedProperty prop, SerializedProperty[] props) { EditorGUILayout.PropertyField(prop, false); if (prop.isExpanded) { for (int i = 0; i < props.Length; i++) { BeginProperty(props[i]); if (props[i].isExpanded) { if (i <= 3) { IKSolverLimbInspector.AddInspector(props[i], false, false); } else if (i == 4) { IKSolverHeuristicInspector.AddInspector(props[i], false, false); } else if (i == 5) { IKSolverAimInspector.AddInspector(props[i], false); } else if (i == 6) { IKSolverLookAtInspector.AddInspector(props[i], false, false); } else if (i == 7) { ConstraintsInspector.AddInspector(props[i]); } } EndProperty(props[i]); } } }
void OnSceneGUI() { // Draw the scene veiw helpers IKSolverHeuristicInspector.AddScene(script.solver, Color.cyan, true); }
protected override void AddInspector() { // Draw the inspector for IKSolverFABRIK IKSolverHeuristicInspector.AddInspector(solver, !Application.isPlaying, false, content); }
protected override SerializedContent[] FindContent() { return(IKSolverHeuristicInspector.FindContent(solver)); }
public void OnEnable() { // 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); // 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.CheckSetup(script.references); } }