示例#1
0
        protected override void AddInspector()
        {
            // Draw the inspector for IKSolverAim
            IKSolverAimInspector.AddInspector(solver, !Application.isPlaying);

            // Warning box
            if (!script.solver.IsValid(false))
            {
                AddWarningBox(script.solver);
            }
        }
示例#2
0
        protected override void AddInspector()
        {
            // Draw the inspector for IKSolverAim
            IKSolverAimInspector.AddInspector(solver, !Application.isPlaying);

            // Warning box
            string message = string.Empty;

            if (!script.solver.IsValid(ref message))
            {
                AddWarningBox(message);
            }
        }
示例#3
0
        /*
         * 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;
                    }
                }
            }
        }
示例#4
0
        /*
         * 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]);
                }
            }
        }
示例#5
0
        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);
            }
        }
示例#6
0
 void OnSceneGUI()
 {
     // Draw the scene veiw helpers
     IKSolverAimInspector.AddScene(script.solver, new Color(1f, 0f, 0.5f, 1f), true);
 }
示例#7
0
 protected override void AddInspector()
 {
     // Draw the inspector for IKSolverAim
     IKSolverAimInspector.AddInspector(solver, !Application.isPlaying, content);
 }
示例#8
0
 protected override SerializedContent[] FindContent()
 {
     return(IKSolverAimInspector.FindContent(solver));
 }