2D Toolkit Forum

2D Toolkit => Support => Topic started by: Siddharth3322 on May 25, 2014, 12:11:08 pm

Title: Sprite Collection with Scene dependency
Post by: Siddharth3322 on May 25, 2014, 12:11:08 pm
I have pretty basic question but answer of this clears my mind very well.

If I have multiple sprite collection and used it for different scene then each get loaded at same time or not?

I don't perform any loading and unloading task. So what is default behaviour of sprite collection?
Title: Re: Sprite Collection with Scene dependency
Post by: unikronsoftware on May 25, 2014, 05:02:33 pm
Same as any asset in unity. Unless you retain persistent references in unity, they will be unloaded when the level gets switched. If in doubt check unity docs for rules, sprites follow the same rules as everything else.
Title: Re: Sprite Collection with Scene dependency
Post by: Siddharth3322 on May 25, 2014, 05:15:52 pm
So if I prepare different sprite collection for each scene then I got benefit that unnecessary collection not get loaded.
Because that sprite collection's sprite not present in screen.

Am I understand right in this?

And one more thing, thanks for your replies and I always get reply from you.
Title: Re: Sprite Collection with Scene dependency
Post by: unikronsoftware on May 25, 2014, 05:28:16 pm
Yes thats correct
Title: Re: Sprite Collection with Scene dependency
Post by: Siddharth3322 on May 26, 2014, 06:21:11 am
Sorry but I want to ask one more question that I forgot yesterday.

For example, I have one sprite collection of 2048 size for whole game and I have followed scene based approach for developing game.
So each scene use same sprite collection. So loading and unload of this sprite collection happened on each scene change or not??

And if loading and unloading happen on each scene change then I don't want to perform this. I want to keep this sprite collection in memory then what to do for this?
Title: Re: Sprite Collection with Scene dependency
Post by: unikronsoftware on May 26, 2014, 10:06:21 am
you can make it permanently persistent by calling Object.DontDestroyOnLoad
Title: Re: Sprite Collection with Scene dependency
Post by: Siddharth3322 on May 26, 2014, 02:48:29 pm
I understand what you say.
But I am little surprised after reading above post.

Actually using DontDestroyOnLoad will keep texture in device memory.
Is it true? Please give some explanation about this.
Title: Re: Sprite Collection with Scene dependency
Post by: unikronsoftware on May 26, 2014, 02:52:45 pm
Read the unity docs. Thats what its there for.