2D Toolkit Forum
2D Toolkit => Support => Topic started by: lwaarbroek on January 08, 2013, 08:39:58 pm
-
Hey all,
Thanks for creating this wonderful plugin.
I was coming across a minor problem though:
I want my animations to be set by using public inspector variables so that artists can set the proper animation for each character they create. For example: in my AnimManager script I've made 4 animations "slots"; run, attack, death and idle. And I want to be able to set each slot by using the animation library and then selecting a clip from that library.
Is something like this possible? Currently I solved it by just typing in the name of the clip but this is quite inconvenient as you have to check your clip names and have typo's etc.
Thanks,
Luuk
-
It is kinda possible, but you will have to code it in.
If everything is from the same library then all you'll need to do is add something like this.
Make a new behaviour and attach it to your animated sprite, or have a link to an animated sprite.
In the inspector code for that behaviour, add something like this
string[] clipNames = new string[sprite.anim.clips.Length];
for (int i = 0; i < sprite.anim.clips.Length; ++i)
clipNames[i] = sprite.anim.clips[i].name;
myTarget.RunClip = EditorGUILayout.Popup("Run", myTarget.RunClip, clipNames);
This code is almost entirely lifted from tk2dSpriteAnimationEditor.cs
Refer to that file for a bit more info, but this is more or less sufficient to do what you were asking.
-
Nice! I'll give it a try as soon as I get home.
Thanks for the quick reply.
Luuk