- Home /
Question by
Mino · Dec 10, 2009 at 10:14 PM ·
animationeditor-scripting
Get a list of clips in an animation component from script.
How can I get a simple list(array) of available AnimationClips in an animation component of a specific GameObject in script?
Or more specifically, how can I get a string array of available animation clip names from a GameObject?
Comment
Best Answer
Answer by Jaap Kreijkamp · Dec 11, 2009 at 02:33 AM
You can iterate over the values:
function GetAnimationNames(Animation anim) // make an Array that can grow var tmpList : Array = new Array();
// enumerate all states
for (var state : AnimationState in anim) {
// add name to tmpList
tmpList.Add(state.name);
}
// convert to (faster) buildin array (but can't grow anymore)
var list : string[] = tmpList.ToBuildin(string);
return list;
}