2D Toolkit Forum
2D Toolkit => Support => Topic started 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:
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
-
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
-
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.
-
YEs I got it working thank you :)
It seemed it did not like it being in a sub folder
-
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.