2D Toolkit Forum

2D Toolkit => Support => Topic started by: edo on January 28, 2014, 11:15:03 am

Title: LoadResourceByName
Post by: edo on January 28, 2014, 11:15:03 am
Hi,
I'm trying to change Sprite Collection at Runtime using:

// init
tk2dSpriteCollectionData fruitCollection;

// start
fruitCollection = tk2dSystem.LoadResourceByName<tk2dSpriteCollectionData>("BananaSpriteCollection") as tk2dSpriteCollectionData;

// function
MyFruitsImage[z].SetSprite(fruitCollection, "Banana_Idle0001");

i've set the loadable asset.
i've build the index again.
i get no error or nothing on run time but it's not working.
any idea why?

tnx,
Edo
Title: Re: LoadResourceByName
Post by: unikronsoftware on January 28, 2014, 11:26:56 am
tk2dSystem.LoadResourceByName is undocumented because it isn't supported / tested for use outside the platform sprite collections. You will have to debug this to work out why it isn't working - if it didn't work I would expect a null ref error.

If you want to load sprite collections at runtime you can always put the data object in a Resources directory and use Resources.Load to load it.