2D Toolkit Forum

2D Toolkit => Support => Topic started by: Benjam901 on November 04, 2013, 08:32:36 pm

Title: Need help changing sprite libraries
Post by: Benjam901 on November 04, 2013, 08:32:36 pm
Hello 2D Toolkit users,

I have a query for you. I am changing my animated sprites library at run time but instead of changing to the library like I want it to it is setting the library to DemoAnimations instead?

I am not sure what I am doing wrong but perhaps I need to have my folders structured inside the TK2D root folders?

The code I am using for this is as follows:

Code: [Select]
void changeLibrary()
{
Destroy(this);
gameObject.AddComponent("Base_Interaction");
getUpSprite.Library = Resources.Load("MovementLib", typeof(tk2dSpriteAnimation)) as tk2dSpriteAnimation;;
}

Any help would be awesome!

Cheers guys :)

Benjam
Title: Re: Need help changing sprite libraries
Post by: Benjam901 on November 04, 2013, 08:51:04 pm
I have also put the libraries and such in a folder called Resources but when I try to load it it returns as a null value
Title: Re: Need help changing sprite libraries
Post by: unikronsoftware on November 05, 2013, 12:06:49 pm
The MovementLib object (the prefab) must be in a resources library for it to load properly using Resources.Load. Also make sure there aren't any other objects with the same name in the resources folder, otherwise it won't load properly.
Title: Re: Need help changing sprite libraries
Post by: Benjam901 on November 06, 2013, 10:19:23 pm
YEs I got it working thank you :)

It seemed it did not like it being in a sub folder
Title: Re: Need help changing sprite libraries
Post by: unikronsoftware on November 06, 2013, 10:26:51 pm
If its in a subfolder you will need that as part of the asset name. So, subfolder/thing instead of thing on its own. I.e. a relative path to the resources folder.