x


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?

more ▼

asked Dec 10 '09 at 10:14 PM

Mino gravatar image

Mino
44 1 1 4

(comments are locked)
10|3000 characters needed characters left

1 answer: sort oldest

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;
}
more ▼

answered Dec 11 '09 at 02:33 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.5k 20 27 71

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x5272
x3929
x351

asked: Dec 10 '09 at 10:14 PM

Seen: 6551 times

Last Updated: Dec 10 '09 at 10:14 PM