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!

You should use state machine behavior to trigger code that should run on state changes / updates.

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.