Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


OnStateEnter

Invoked on the first update frame when a state machine evaluates this state. Implement this message to react to a new state starting.
Read time 1 minuteLast updated 5 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.AnimationModule

OnStateEnter(Animator, AnimatorStateInfo, int)

Invoked on the first update frame when a state machine evaluates this state. Implement this message to react to a new state starting.
public virtual void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)

Parameters

animator

The Animator evaluating this state machine.


layerIndex

The current layer being evaluated.

Remarks

OnStateEnter is invoked when a transition to a state is initiated. It will be invoked after OnStateUpdate of the current state.
Note: OnStateEnter may be invoked multiple times on the same state if that state is synchronized on multiple layers.

OnStateEnter(Animator, AnimatorStateInfo, int, AnimatorControllerPlayable)

Invoked on the first update frame when a state machine evaluates this state. Implement this message to react to a new state starting.
public virtual void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex, AnimatorControllerPlayable controller)

Parameters

animator

The Animator evaluating this state machine.


layerIndex

The current layer being evaluated.

Remarks

OnStateEnter is invoked when a transition to a state is initiated. It will be invoked after OnStateUpdate of the current state.
Note: OnStateEnter may be invoked multiple times on the same state if that state is synchronized on multiple layers.