Hello Guest

Author Topic: can not get sprite collection data problem.  (Read 4016 times)

serenobs

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 4
    • View Profile
can not get sprite collection data problem.
« on: January 10, 2013, 01:44:12 pm »
Hello.

I found there are some threads about the topic, but I couldn't solve my errors. I'm using unity 4 and 1.80 + patch 3.
I'm trying to create a sprite dynamically in Javascript but I couldn't get valid sprite collection data by Resource.Load("name").
Here is my code.
      var collectionData : tk2dSpriteCollectionData = Resources.Load("MySpriteCollection2") as tk2dSpriteCollectionData;
I created a "sprite collection" named MySpriteCollection, and I noticed the file generated a "sprite collection data" with the same name in a new folder. So I changed the file's name as MySpriteCollection2 and moved the file into the resources folder. Actually I'm not quite sure if I should use the default resources folder or is it okay to create another folder in different place with the same name.

But still it returns NULL. What should I do now?

Thanks

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: can not get sprite collection data problem.
« Reply #1 on: January 12, 2013, 02:04:45 pm »
You can create the sprite collection in any directory. Why do you rename the sprite collection inside the data folder? You can have more than one resources folder.

SpriteColl2 (sprite collection)
   SpriteColl2 Data
        SpriteColl2 (sprite collection data)
        Atlas, etc.

TO

SpriteColl2 (sprite collection)
   SpriteColl2 Data
        Atlas, etc.
        Resources
            SpriteColl2 (sprite collection data)

Loading like that should work, as long as the object is in resources.
Is this how its set up?