Please tell me, what is the easiest way to programmaticaly create tk2dSprite in toolkit2d(unity)? So I have .png image in assets/image from which sprite must be created. I want to create sprite, and then show it on the scene.
1 Answers
1
votes
I am not at my computer but try something like (C#):
string spriteName = "spriteInSpriteCollection";
GameObject spriteObject = new GameObject();
tk2dSprite spriteComponent = spriteObject.AddComponent<tk2dSprite>();
spriteComponent.SetSprite(spriteName);
I would test this and see if the component could be created and initialized with the sprite before adding it to the object but I can't right now, hopefully this points you in the right direction though.
Edited to include improvement by SlxS.