2D Toolkit Forum
2D Toolkit => Support => Topic started by: David Kalina on November 08, 2013, 11:58:22 pm
-
I want to write a class that refers to a tk2dSprite by collection and name, and ideally I'd like it to show up in the editor with the same picker utility that exists for the tk2dSprite class.
I could just point my class at instances of tk2dSprite GameObjects but I'm looking for the more fancy editor solution. I also don't really want to create a ton of GameObjects in the hierarchy specifically so I can draw lines to them -- I'd rather my data structure show the thing it refers to immediately in the inspector.
Is there a fast and easy way to do this? I started trying to pick apart the tk2dSpriteEditor code but it's late Friday afternoon and I'm not super engaged at the moment :)
Thanks, have a great weekend!
-
Its fairly straightforward.
This line draws the sprite picker
tk2dSpriteGuiUtility.SpriteSelector( currentCollection, currentSpriteId, SpriteChangedCallbackImpl, null );
It uses a callback to assign the sprite when switched:
void SpriteChangedCallbackImpl(tk2dSpriteCollectionData spriteCollection, int spriteId, object data)
{
// sprite changed, assign here
}