Beispiel #1
0
        public bool ValidateAnimator(bool createMissing = false)
        {
            var a = GetComponent <Animator> ();

            if (a == null && !createMissing)
            {
                return(false);
            }

            if (a == null)
            {
                a = this.gameObject.AddComponent <Animator> ();
            }

            UnityEditor.Animations.AnimatorController c;
            if (!ParamEditorExt.GetAnimatorController(this, out c) && !createMissing)
            {
                return(false);
            }

            if (c == null)
            {
                c = AnimatorTemplate.CreateAnimatorController("ShowHidePanelViewTemplate", this.name);
                if (c != null)
                {
                    UnityEditor.Animations.AnimatorController.SetAnimatorController(a, c);
                }
                return(c != null);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Check whether the setup for a ShowHidePanel view has all required components including parameters on AnimatorController asset.
        /// Optionally, tries to create missing parameters.
        /// </summary>
        public bool ValidateAnimatorParameters(bool createMissing = true)
        {
            UnityEditor.Animations.AnimatorController c;

            return(ParamEditorExt.GetAnimatorController(this, out c) &&
                   ValidateShowParam(createMissing) &&
                   ValidateShowingParam(createMissing) &&
                   ValidateHiddenParam(createMissing) &&
                   ValidateImmediateParam(createMissing));
        }
Beispiel #3
0
        public bool ValidateParam <T>(bool createMissing = false) where T : Component, Param
        {
            var p = GetComponent <T> ();

            if (p == null && (!createMissing || (p = this.AddIfMissing <T> ()) == null))
            {
                return(false);
            }

            UnityEditor.Animations.AnimatorController c;
            if (!ParamEditorExt.GetAnimatorController(this, out c))
            {
                return(false);
            }

            return(p.ValidateAnimatorControllerParam(createMissing));
        }
Beispiel #4
0
 public bool ValidateImmediateParam(bool createMissing = true)
 {
     UnityEditor.Animations.AnimatorController c;
     return(ParamEditorExt.GetAnimatorController(this, out c) &&
            ParamEditorExt.ValidateAnimatorControllerParam(c, ParamExt.DefaultParamNameRemovingSuffixes <ImmediateTrigger> ("Trigger"), typeof(Invocable), createMissing));
 }
Beispiel #5
0
 public bool ValidateShowParam(bool createMissing = true)
 {
     UnityEditor.Animations.AnimatorController c;
     return(ParamEditorExt.GetAnimatorController(this, out c) &&
            ParamEditorExt.ValidateAnimatorControllerParam(c, ParamExt.DefaultParamName <Show> (), typeof(bool), createMissing));
 }