2D Toolkit Forum
2D Toolkit => Support => Topic started by: Majicpanda on September 09, 2013, 05:24:45 am
-
I want to use ScriptableObjects for my monsters in my game so that I can load up the data from them. The issue I can't seem to figure out is how to get the sprite to show up in the inspector besides just using a public tk2dSpriteCollectionData monsterData ref to my monster atlas and then do a workflow that all monster names exactly match a sprite in the data and do SetSprite(monsterData, monsterName), but I was hoping for something a bit more concrete and not error prone.
-
Create a custom editor (inspector) for your scriptable object, then for the sprite collection data / spriteId pair, use something like this:
tk2dSpriteGuiUtility.SpriteSelector( targetSprites[0].Collection, targetSprites[0].spriteId, spriteChangedCallbackInstance, null );
Refer to tk2dSpriteEditor for more details on the additional requirements (spriteChangedCallbackInstance) for this.