using System.Collections; using System.Collections.Generic; using UnityEngine; namespace MoreMountains.Tools { /// /// A helper class that will hash a animation parameter and update it on demand /// [AddComponentMenu("More Mountains/Tools/Animation/MMAnimationParameter")] public class MMAnimationParameter : MonoBehaviour { /// the name of the animation parameter to hash public string ParameterName; /// the animator to update public Animator TargetAnimator; protected int _parameter; /// /// On awake we initialize our class /// protected virtual void Awake() { Initialization(); } /// /// Hashes the parameter name into an int /// protected virtual void Initialization() { _parameter = Animator.StringToHash(ParameterName); } /// /// Sets the trigger of the specified name /// public virtual void SetTrigger() { TargetAnimator.SetTrigger(_parameter); } /// /// Sets the int of the specified name to the specified value /// public virtual void SetInt(int value) { TargetAnimator.SetInteger(_parameter, value); } /// /// Sets the float of the specified name to the specified value /// public virtual void SetFloat(float value) { TargetAnimator.SetFloat(_parameter, value); } /// /// Sets the bool of the specified name to the specified value /// public virtual void SetBool(bool value) { TargetAnimator.SetBool(_parameter, value); } } }