2D Toolkit Forum

2D Toolkit => Support => Topic started by: peterbrinson on July 21, 2013, 04:17:18 am

Title: does swapping a tk2dSprite's sprite mean you're using twice a much RAM?
Post by: peterbrinson on July 21, 2013, 04:17:18 am
My scene has 10 GameObjects, each a tk2dSprite.  Each one is based on a unique sprite/image and everything is arranged carefully in the scene editor. 
At scene start, there’s a 50/50 chance I want to swap each of these with a different set of 10 sprite/images. 

I’d like to only load 10 images into memory as they are very wide and tall (png’s). 

- If on ‘Start()’, I swap each of the 10 with different sprite/images, does that mean 20 images are loaded into memory, even for a brief moment? (I'm naive about how unused sprite/images unload, and if they do). 

Btw, these images are mostly set up in sprite collections by themselves because they are so big. 
Title: Re: does swapping a tk2dSprite's sprite mean you're using twice a much RAM?
Post by: unikronsoftware on July 21, 2013, 12:22:07 pm
The sprites don't unload unless you destroy all instances of them and call "UnloadTextures" or Resources.UnloadUnusedAssets. As long as there is a reference to something in Unity, it will load in.
Title: Re: does swapping a tk2dSprite's sprite mean you're using twice a much RAM?
Post by: unikronsoftware on July 21, 2013, 05:38:26 pm
Yes.
Title: Re: does swapping a tk2dSprite's sprite mean you're using twice a much RAM?
Post by: peterbrinson on July 21, 2013, 05:43:22 pm
I shouldn't have deleted my reply.  I asked if loading a new scene also unloads unused assets.  You can see his reply "Yes" above.