Esempio n. 1
0
        /// <summary>
        /// Get an animation to play. This requires the use of action fields 0-3.
        /// </summary>
        /// <param name="title">Title of the action field.</param>
        /// <param name="actionParams">Action parameters.</param>
        /// <param name="actionFieldA">Action field.</param>
        /// <param name="actionFieldB">Action field.</param>
        /// <param name="actionFieldC">Action field.</param>
        /// <param name="paramType">Animation controller parameter type.</param>
        /// <param name="targetHeroObject">The target hero object.</param>
        public static void GetAnimation(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, HeroActionField actionFieldC, AnimatorControllerParameterType paramType, HeroObject targetHeroObject)
        {
            if (title != "")
            {
                SimpleLayout.Label(title);
            }

            SimpleLayout.BeginVertical(Box.StyleB);

            if (targetHeroObject == null)
            {
                SimpleLayout.Label("Select a hero object to see its animation parameters.");
                SimpleLayout.EndVertical();
                return;
            }

            if (targetHeroObject.states.states == null || targetHeroObject.states.states.Count == 0)
            {
                SimpleLayout.Label("This hero object has no states.");
                SimpleLayout.EndVertical();
                return;
            }

            SimpleLayout.Label("The state that contains the animation controller:");
            int stateID = GetDropDownBField.BuildField("", actionParams, actionFieldA, new HeroField.StateListField(), targetHeroObject.states.states) - 1;

            if (stateID >= 0)
            {
                string paramTypeName = paramType.ToString();

                SimpleLayout.Label(paramTypeName + " assigned to the animation controller:");
                RuntimeAnimatorController animatorController = GetAnimationParameterField.BuildFieldA("", actionParams, actionFieldB, targetHeroObject, stateID, paramType);

                if (animatorController == null)
                {
                    SimpleLayout.BeginVertical(Box.StyleA);
                    SimpleLayout.Label("This state has no animation controller.\nIf you are 100% certain a specific animation controller\nwill be available at runtime, drag the prefab \nthat contains the controller here:");
                    GameObject prefab = GetPrefabValue.BuildField("", actionParams, actionFieldC);
                    if (prefab != null)
                    {
                        Animator animator = prefab.GetComponent <Animator>();
                        if (animator != null)
                        {
                            animatorController = animator.runtimeAnimatorController;
                            if (animatorController != null)
                            {
                                GetAnimationParameterField.BuildFieldB("", actionParams, actionFieldB, animatorController, paramType);
                            }
                        }
                    }

                    SimpleLayout.EndVertical();
                }
            }

            SimpleLayout.EndVertical();
        }
Esempio n. 2
0
        /// <summary>
        /// Get an animation to play. This requires the use of action fields 0-3.
        /// </summary>
        /// <param name="title">Title of the action field.</param>
        /// <param name="actionParams">Action parameters.</param>
        /// <param name="actionFieldA">Action field.</param>
        /// <param name="actionFieldB">Action field.</param>
        /// <param name="actionFieldC">Action field.</param>
        /// <param name="paramType">Animation controller parameter type.</param>
        /// <param name="targetHeroObject">The target hero object.</param>
        public static void GetAnimation_Legacy(string title, HeroActionParams actionParams, HeroActionField actionFieldA, HeroActionField actionFieldB, HeroActionField actionFieldC, HeroObject targetHeroObject)
        {
            if (title != "")
            {
                SimpleLayout.Label(title);
            }

            SimpleLayout.BeginVertical(Box.StyleB);

            if (targetHeroObject == null)
            {
                SimpleLayout.Label("Select a hero object to see its animations.");
                SimpleLayout.EndVertical();
                return;
            }

            if (targetHeroObject.states.states == null || targetHeroObject.states.states.Count == 0)
            {
                SimpleLayout.Label("This hero object has no states.");
                SimpleLayout.EndVertical();
                return;
            }

            SimpleLayout.Label("The state that contains the animations:");
            int stateID = GetDropDownBField.BuildField("", actionParams, actionFieldA, new HeroField.StateListField(), targetHeroObject.states.states) - 1;

            if (stateID >= 0)
            {
                SimpleLayout.Label("The animation to play:");
                Animation animation = GetAnimationParameterField.BuildFieldA_Legacy("", actionParams, actionFieldB, targetHeroObject, stateID);

                if (animation == null)
                {
                    SimpleLayout.BeginVertical(Box.StyleA);
                    SimpleLayout.Label("This state has no animation component.\nIf you are 100% certain a specific animation component\nwill be available at runtime, drag the prefab \nthat contains the component here:");
                    GameObject prefab = GetPrefabValue.BuildField("", actionParams, actionFieldC);
                    if (prefab != null)
                    {
                        animation = prefab.GetComponent <Animation>();
                        if (animation != null)
                        {
                            GetAnimationParameterField.BuildFieldB_Legacy("", actionParams, actionFieldB, animation);
                        }
                    }

                    SimpleLayout.EndVertical();
                }
            }

            SimpleLayout.EndVertical();
        }
Esempio n. 3
0
        public static void BuildField(HeroActionParams actionParams)
        {
            HeroAction heroAction = actionParams.heroAction;

            //-----------------------------------------
            // create the action fields if they don't exist
            //-----------------------------------------
            ActionCommon.CreateActionFieldsOnHeroObject(heroAction, 3);

            //-----------------------------------------
            // create the fields for this action
            //-----------------------------------------
            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            HeroObject targetHeroObject = GetHeroObjectField.BuildFieldE("Change a different object?", actionParams, heroAction.actionFields[0], heroAction.actionFields[1]);

            SimpleLayout.EndVertical();

            if (targetHeroObject == null)
            {
                SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                SimpleLayout.Label("This field does not have a hero object type assigned to it.");
                SimpleLayout.EndVertical();
                return;
            }

            if (targetHeroObject.states.states == null || targetHeroObject.states.states.Count == 0)
            {
                SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
                SimpleLayout.Label("This hero object has no states.");
                SimpleLayout.EndVertical();
                return;
            }

            SimpleLayout.BeginVertical(SimpleGUI.Fields.Box.StyleB);
            GetDropDownBField.BuildField("Change hero object to this state:", actionParams, heroAction.actionFields[2], new HeroField.StateListField(), targetHeroObject.states.states);
            SimpleLayout.EndVertical();
        }