- Home /
How can i retrieve the list of all animator state name from a script editor?
I want to retrieve the list of all animator state name from a script editor. Is it possible? I didn't find any working solutions yet. I'm using Unity version 5.3.
I want to make a script editor that allow to set an AudioClip to play when entering in an animator state. So, that why i need the list of all animator state that exist within the animator. Otherwise, i will have to hardcode the list but i want to avoid doing that.
Thanks!
Answer by fffMalzbier · Dec 15, 2015 at 09:42 AM
You should use state machine behavior to trigger code that should run on state changes / updates.
https://unity3d.com/learn/tutorials/modules/beginner/5-pre-order-beta/state-machine-behaviours
You can check if a animator has a specific state with Animator.HasState but there is is no way to get a list of all states in a animator at runtime.
Your answer
Follow this Question
Related Questions
"StateMachineBehaviour" Not working for sub sates ? 0 Answers
Animation plays only once 1 Answer
Transition to multiple states from Entry Node in Unity 5 1 Answer
how to fix roll animation resets to animation start position 0 Answers
[StateMachineBehaviours] All prefabs share same state machine. 0 Answers