Skip to content

AnimatorStateInfo

extends EngineObject

The AnimationStateInfo class is used to retrieve information about the currently playing animation clip, including the current playback time, the length of the animation clip, the number of loops, and more.

You can obtain an AnimationStateInfo object using the following method:

typeScript
let go = new GameObject("StateInfo");
let animator = go.AddComponent<Animator>(Animator);
let data = Resources.Load<AnimatorData>(AnimatorData, "461E6F10246D4A0638921370728F3D10");
let stateInfo = actor.GetCurrentStateInfo(0);

成员变量

AnimatorStateInfo.name : string
(Read Only) The name of the state.
AnimatorStateInfo.isValid : boolean
(Read Only) Whether the current state is valid.
AnimatorStateInfo.speed : number
(Read Only) The playback speed of the animation.
AnimatorStateInfo.normalizedStateTime : number
(Read Only) The normalized time of the current state.
AnimatorStateInfo.stateTime : number
(Read Only) The time of the current animation state.

成员方法

AnimatorStateInfo.IsName ( name : string ) : boolean
Checks if the current name matches the name of the active state in the state machine.