Hide
AnimatorState

A dropdown selector for animator state.

  • string animatorName=null

    name of the animator. When omitted, it will try to get the animator from the current component

to get more useful info from the state, you can use AnimatorStateBase/AnimatorState type instead of string type.

AnimatorStateBase has the following properties:

  • int layerIndex index of layer
  • int stateNameHash hash value of state
  • string stateName actual state name
  • float stateSpeed the Speed parameter of the state
  • string stateTag the Tag of the state
  • string[] subStateMachineNameChain the substate machine hierarchy name list of the state

AnimatorState added the following attribute(s):

  • AnimationClip animationClip is the actual animation clip of the state (can be null). It has a length value for the length of the clip. For more detail see Unity Doc of AnimationClip

Special Note: using AniamtorState/AnimatorStateBase with OnValueChanged, you will get a AnimatorState on the callback.

using SaintsField; [AnimatorState] public string stateName; [AnimatorState(nameof(MyAnimator))] // you can specific an animator public AnimatorState state; public AnimatorStateBase stateBase;

animator_state

It works with ShowInInspector:

[ShowInInspector] private AnimatorState ShowAnimatorState { get => animatorState; set => animatorState = value; }

It works with ShowInInspector/Button parameters and return value

[ShowInInspector] [AnimatorState] private string ShowAnimatorState([AnimatorState] string animName) => animName; [Button] [AnimatorState] private string ShowAnimatorState([AnimatorState] string animName) => animName;