Get the clip length (accounting for speed multipliers) of any animation state at runtime


Although I can look up the base length of whatever clip is currently being used by a state via animator.runtimeAnimatorController, I cannot account for the state’s various speed multipliers that will affect the final clip length.

The multipliers are available in AnimatorStateInfo, but Unity only gives us GetCurrentAnimatorStateInfo and GetNextAnimatorStateInfo. I would like to be able to access this information for any state in the animator. It’s really surprising that something like GetAnimatorStateInfo(string stateName) does not exist. Is there another way?


In my 2D game, the player’s animator controller has some fixed set of states (idle, move, action, etc.).

I use AnimatorOverrideController to change the clips associated with these states dynamically at runtime, e.g. equipping a tool changes the clip associated with the “action” state.

I use speed parameters in the animator controller to adjust the speed of a state dynamically for things like movement speed, but I’m also adjusting the state’s actual speed as a convenient way to fine tune the base speed of the animation clips.

Hard coding the speed values is out, and I would also like to avoid changing the frame rate of the clips themselves in the animation view as this is very slow and difficult to make tweaks. Thanks in advance!

I asked this question over on the Unity forums and per Mecanim-Dev it sounds like it is not possible.