Hello Guest

Author Topic: When are Atlas Textures loaded?  (Read 5403 times)

Charriu

  • Newbie
  • *
  • Posts: 1
    • View Profile
When are Atlas Textures loaded?
« on: April 26, 2012, 01:58:35 pm »
Hi,

I'm currently working on a project for iOS/Android. My problem is that I have many graphics in one Unity Scene and they are using to much memory space on the mobilephone (something above 120 MB).

So I wondered when the atlas textures are loaded? Are they loaded when the scene is loaded or is there a way to load the atlas texture only when the gameobject becomes active and unload it when the gameobject becomes inactive?

Thanks so far

39thstreet

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 77
    • View Profile
Re: When are Atlas Textures loaded?
« Reply #1 on: April 26, 2012, 03:30:51 pm »

They way I'm approaching this is to make use of the Unity Resources folder. You can export an asset/prefab there and it will not load until you explicitly call Resources.Load and instantiate.   This is, I believe, how this is generally done in Unity and it seems to work fine with 2dToolKit:

http://unity3d.com/support/documentation/ScriptReference/Resources.Load.html


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: When are Atlas Textures loaded?
« Reply #2 on: April 26, 2012, 06:31:52 pm »
That is one way to do it, another is to load a second scene in additively with the bits you're interested in. That might work out better if you want to position things visually. You're still responsible for deleting the relevant objects and calling Resources.UnloadUnusedAssets() after that.

A third option is to use AssetBundles, but I can't see much of an advantage over putting stuff in "Resources".

Don't forget to call Resources.UnloadUnusedAssets after destroying your loaded sprites, thats what will actually free the textures, etc.