Skip to content

Instantly share code, notes, and snippets.

@quickfingers
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save quickfingers/421b32aaf99ccba70ee7 to your computer and use it in GitHub Desktop.

Select an option

Save quickfingers/421b32aaf99ccba70ee7 to your computer and use it in GitHub Desktop.
Getting a list of mecanim states in Animator 4.3+
UnityEditorInternal.AnimatorController ac = GetComponent<Animator>().runtimeAnimatorController as UnityEditorInternal.AnimatorController;
UnityEditorInternal.StateMachine sm = ac.GetLayer(0).stateMachine;
for (int i = 0; i < sm.stateCount; i++)
{
UnityEditorInternal.State state = sm.GetState(i);
Debug.Log(string.Format("State: {0}", state.uniqueName));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment