/************************************************************************************************************************/

        /// <summary>[Animancer Extension]
        /// Returns the <see cref="AnimancerComponent"/> on the same <see cref="GameObject"/> as the 'animator' if
        /// there is one. Otherwise this method adds a new one and returns it.
        /// </summary>
        public static AnimancerComponent GetOrAddAnimancerComponent(this Animator animator)
        {
            var animancer = animator.GetComponent <AnimancerComponent>();

            if (animancer != null)
            {
                return(animancer);
            }
            else
            {
                return(animator.AddAnimancerComponent <AnimancerComponent>());
            }
        }
Esempio n. 2
0
        /************************************************************************************************************************/

        /// <summary>[Animancer Extension]
        /// Returns the <see cref="IAnimancerComponent"/> on the same <see cref="GameObject"/> as the `animator` if
        /// there is one. Otherwise this method adds a new one and returns it.
        /// </summary>
        public static T GetOrAddAnimancerComponent <T>(this Animator animator) where T : Component, IAnimancerComponent
        {
            var animancer = animator.GetComponent <T>();

            if (animancer != null)
            {
                return(animancer);
            }
            else
            {
                return(animator.AddAnimancerComponent <T>());
            }
        }
 /// <summary>
 /// Adds an <see cref="AnimancerComponent"/>, links it to the 'animator', and returns it.
 /// </summary>
 public static AnimancerComponent AddAnimancerComponent(this Animator animator)
 {
     return(animator.AddAnimancerComponent <AnimancerComponent>());
 }