Hello Guest

Author Topic: Sprite Collection with Scene dependency  (Read 5339 times)

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Sprite Collection with Scene dependency
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #1 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.

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #2 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #3 on: May 25, 2014, 05:28:16 pm »
Yes thats correct

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #4 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #5 on: May 26, 2014, 10:06:21 am »
you can make it permanently persistent by calling Object.DontDestroyOnLoad

Siddharth3322

  • Newbie
  • *
  • Posts: 29
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #6 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.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Sprite Collection with Scene dependency
« Reply #7 on: May 26, 2014, 02:52:45 pm »
Read the unity docs. Thats what its there for.