Hello Guest

Author Topic: Unload atlases by temporary removing references from sprites  (Read 2311 times)

Finnegan

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Unload atlases by temporary removing references from sprites
« on: August 22, 2014, 01:54:29 pm »
We have memory pressure problems on some iOS devices. Many collections have been optimized already, but the inability to unload atlases without destroying sprites keeps us from effective memory management.

I got an idea about this kind of hack:
* use "Loadable Asset" in collection settings
* add vars "originalSpriteName" and "originalCollectionName" to tk2dBaseSprite
* cache current name and collection to them
* switch the sprite to some tiny placeholder sprite from tiny collection
* references to the original atlas are gone now
* Resources.UnloadUnusedAssets();
* reload original collection and sprites on demand with tk2dSystem.LoadResourceByName<tk2dSpriteCollectionData>(collName) and SetSprite

Will it work? Thanks.
« Last Edit: August 22, 2014, 02:01:59 pm by Finnegan »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unload atlases by temporary removing references from sprites
« Reply #1 on: August 22, 2014, 07:47:53 pm »
Sounds like it will work, but I really can't say for certain. Only way to find out is to implement it and benchmark...