2D Toolkit Forum
2D Toolkit => Support => Topic started by: fxfx on June 17, 2015, 04:43:48 pm
-
I am trying to get a list of all sprite names in a Sprite Collection during runtime. I put the data file in Resources folder, and then try to get all the names by code:
tk2dSpriteCollectionData atlas = Resources.Load("atlas", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
foreach (tk2dSpriteDefinition spritedefinition in atlas.spriteDefinitions) {
Debug.Log(spritedefinition.name);
}
The weird thing is that it works for one Sprite Collection, and not the other. The other Sprite Collection is showing 0 spriteDefinitions count.
I checked and the only difference between the two Sprite Collection is that the one returning 0 has 3 platforms (@1x, @2x, @4x)
Any help will be appreciated. Thanks!
-
If it has platforms, you should use atlas.inst.spriteDefinitions. That will return the loaded platform collection. In fact you can safely do that all the time.
-
It works. Thanks! :)