Hello Guest

Author Topic: Spritedefinitions returning zero  (Read 3372 times)

fxfx

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Spritedefinitions returning zero
« 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!

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Spritedefinitions returning zero
« Reply #1 on: June 17, 2015, 06:17:50 pm »
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.

fxfx

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Spritedefinitions returning zero
« Reply #2 on: June 17, 2015, 07:25:45 pm »
It works. Thanks!  :)