Hello Guest

Author Topic: Multiple Atlas - all loaded into memory at once?  (Read 6235 times)

laptin

  • Newbie
  • *
  • Posts: 2
    • View Profile
Multiple Atlas - all loaded into memory at once?
« on: June 25, 2012, 06:26:48 am »
Sorry if this has been answered but I couldn't find it anywhere in the forum.

If I enabled multiple atlas for a Sprite Collection, and I have 3 multiple atlases created from all my images. During runtime, do all 3 atlases get loaded into memory at once even if I am using a sprite from only 1 of the 3 altas?

-laptin

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Multiple Atlas - all loaded into memory at once?
« Reply #1 on: June 25, 2012, 10:26:24 am »
Hi,

They will all be loaded in at runtime. The multi atlas feature is mainly for larger animations, and as such all atlases would need to be present.

laptin

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Multiple Atlas - all loaded into memory at once?
« Reply #2 on: June 25, 2012, 01:32:44 pm »
Thanks for the quick response.

Too late into the project now for me as I have been using the multi-atlas incorrectly. I didn't know all atlases would be loaded.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Multiple Atlas - all loaded into memory at once?
« Reply #3 on: June 25, 2012, 02:38:38 pm »
Out of curiosity, how were you using it?

The order in the atlases is undefined (at least to the end user) so any sprite may end up in any one of the atlases, so there isn't really any way to support this "properly", unless if you were to say this texture goes into atlas A, and so on, but in that case, you'll be better off just making multiple sprite collections.

dakeese

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 50
    • View Profile
Re: Multiple Atlas - all loaded into memory at once?
« Reply #4 on: July 22, 2012, 09:16:41 am »
I have a related, more general question.

How does Unity know which sprite collections to load when a scene loads?  Is it the existence of a at least one sprite in the hierarchy that uses that collection in the Scene file?

If so, is it possible to load a sprite in code if it is not part of a sprite collection that was in the hierarchy of the scene file? Or, more practically, is it possible to force a sprite collection to load with a scene even if the scene does not initially reference any sprites from that collection?

I'm a bit unclear in general how Unity knows what to load in a scene, in terms of textures and models.  Is it just anything that is specified in the hierarchy?  So if you instantiate something in code that uses a texture that wasn't initially related to any objects in the scene's hierarchy, you will potentially be causing a small loading hiccup for that texture?

...oops, stream of thoughts there. That turned into more than one question. :)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Multiple Atlas - all loaded into memory at once?
« Reply #5 on: July 22, 2012, 09:50:22 am »
Pretty much what you said, though I think it only uploads the texture to VRAM when it is first visible. This was definitely true in an older version, but I haven't checked what it does now. Everything in the scene is loaded in at startup, and if you instantiate something, that is loaded in at when instantiated, unless you already have a reference to the Sprite Collection Data object in the scene in which case it'd have loaded it in already at scene load time.