2D Toolkit Forum
2D Toolkit => Support => Topic started by: MrAdventure on July 13, 2016, 09:14:31 pm
-
Hello,
How does one make an array of sprites and be able to assign the different sprites in editor?
Here's what I've got, which gives me an array of Tk 2d Sprite in editor.
public tk2dSprite[] hitSprites;
// Use this for initialization
void Start () {
hitSprites = GetComponentsInChildren<tk2dSprite> ();
When trying to assign the sprites, the pop up dialog has none available.
Thanks
-
I'm not sure waht you're trying to do here - is it an editor that displays all these sprites in one inspector?
-
This picture may explain better.
.... Oops, no way to insert it.
Ok, so I'm trying to use an array to iterate through sprites. I want to apply the specific sprites within the editor.
In the array within the editor, the elements are specifically for Tk 2d Sprite. It is drag in to fill, or click the circle to choose from all of that type. When clicking, the dialog that pops up has no available Tk 2d Sprites, even though I have lots made.
They are in collections, of course. So how would I go about being able to apply specific tk2d sprites to fields within the editor?
Thanks
-
You'll need to write your own inspector. The object inspector will not pick up a tk2d sprite reference as it is an object + int reference, not just an object. Refer to the sprite editor class for how to do this - the speciifc line to start looking is this:
tk2dSpriteGuiUtility.SpriteSelector( targetSprites[0].Collection, targetSprites[0].spriteId, spriteChangedCallbackInstance, null );
-
So there isn't a built in way to iterate through tk2D sprites in code?
-
You can iterate through them using foreach etc, just need to build the inspector yourself in OnInspectorGUI.