Accessing Animation Component's AnimationState's in the Editor...

I’ve learned that the Animation (legacy) component is an enumerable, and so it can be iterated over to access the AnimationStates in its array. This is great, however the enumerator doesn’t seem to be updated until runtime begins!

I am writing a little AnimationHelper script to push AnimationStates into their appropriate default layers, etc, and in its custom inspector it iterates over the states on the local Animation component. When I change the states (add or remove a clip), my inspector does not return the changes until after I have entered the runtime environement.

Whats going on here and is there any way to “commit” the updated animations to the array without entering runtime?

It seems the best answer is to use AnimationUtility.GetAnimationClips(animationComponent), though this does not return the AnimationState values, as they are created at runtime from the animation clips on the component.

1 Like

Thanks a lot for this, I’ve been trying to figure out for years now.

Thanks,
jrDev