2D Toolkit Forum

2D Toolkit => Support => Topic started by: Dajuice on August 07, 2013, 09:17:10 pm

Title: My Collection, what do I do to reload it?
Post by: Dajuice on August 07, 2013, 09:17:10 pm
The textures now are unloaded, Great Job! :D

But I can't reload them :/

I have to unload textures from my UI, which are sprites that are directly in the scene, I manually delete in the editor the instance that uses the texture, unload the texture, then I put back another instance that uses the texture, the texture won't come back. Even worse, when I stop the test, the texture won't come back either, I need to save the project, then everything is reset to normal. Anything I could to to reload the texture?
Title: Re: My Collection, what do I do to reload it?
Post by: Dajuice on August 07, 2013, 09:53:54 pm
Nevermind,

public void ReloadTextures() {
      renderer.sharedMaterial.mainTexture = renderer.sharedMaterial.mainTexture as Texture2D;
   }

did the trick... it's working even easier than I ever dreamed of!
Title: Re: My Collection, what do I do to reload it?
Post by: unikronsoftware on August 07, 2013, 10:16:13 pm
Thats a lovely one, really. Not sure if its a Unity bug or not, but sure looks like one. Thanks for reminding me that I should file a bug report when I get a chance.
Title: Re: My Collection, what do I do to reload it?
Post by: Dajuice on August 08, 2013, 01:57:28 pm
haha yeah that's strange, but in the meantime this "bug" makes life sooo much easier! I don't even have to destroy/change my sprite and it all works perfectly only with 2 calls!