Hello!
Is there a way, in an editor script, to find the name of the clip attached to the default (orange) animation from the Animator component?
We’re able to get the nameHash, but we need to get a reference to the clip itself (from the project).
Thanks!
TonyLi
2
You can do this in the editor using UnityEditorInternal, but I don’t know any way to get it in a build. Say you already have nameHash and layer:
UnityEditorInternal.AnimatorController ac = GetComponent<Animator>().runtimeAnimatorController as UnityEditorInternal.AnimatorController;
UnityEditorInternal.State defaultState = ac.GetLayer(layer).stateMachine.GetState(nameHash);
string defaultClipName = defaultState.name;
AnimationClip defaultClip = defaultState.GetMotion();
(Pardon typos; I typed straight into the forum editor.)
1 Like
Awesome, thanks – we were thinking it’d be an internal thing. Thanks so much!