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?
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?
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;
}