Hello Guest

Author Topic: Need help changing sprite libraries  (Read 3731 times)

Benjam901

  • Newbie
  • *
  • Posts: 12
    • View Profile
Need help changing sprite libraries
« 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

Benjam901

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Need help changing sprite libraries
« Reply #1 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Need help changing sprite libraries
« Reply #2 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.

Benjam901

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Need help changing sprite libraries
« Reply #3 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Need help changing sprite libraries
« Reply #4 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.