Hello Guest

Author Topic: Unused atlas textures still loaded after LoadLevel  (Read 19582 times)

int64

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Unused atlas textures still loaded after LoadLevel
« Reply #15 on: June 07, 2013, 02:08:38 am »
I have same problem.
In empty scene, loaded after main menu scene (even no camera, absolutely empty scene!), after UnloadUnusedAssets menu atlases, materials and collection prefabs are still loaded in memory.


UPD:
tk2d was updated to 2.0, in special empty scenes I wrote:

Code: [Select]
...
Object[] txt = GameObject.FindObjectsOfTypeIncludingAssets(typeof(GameObject));
for (int i = 0; i < txt.Length; i++)
if (txt[i].name.Length >= 18)
if (txt[i].name.Substring(0, 18) == "Interface_mainMenu"){ //my sprite collection prefab name that need to be unloaded
tk2dSpriteCollectionData t = (txt[i] as GameObject).GetComponent< tk2dSpriteCollectionData>();
if (t)t.UnloadTextures();
};
...

and rewrote tk2dSprite.cs and tk2dSlicedSprite.cs UpdateMaterial() function with this:

Code: [Select]
...
protected override void UpdateMaterial()
{
renderer.sharedMaterial = collectionInst.spriteDefinitions[spriteId].material;
}
...

UnloadTextures() function frees up a lot of memory, and rewriting of UpdateMaterial() function fixes a bug with black textures in sprite materials when scene with unloaded spritecollection has been reloaded.

P.S.: sorry for my bad English
« Last Edit: June 07, 2013, 07:26:13 am by int64 »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Unused atlas textures still loaded after LoadLevel
« Reply #16 on: June 07, 2013, 09:25:54 am »
@int64 - what features do you use? Do you use platform sprite collections, do you load them in using Resources.Load? Hard to guess whats going on - I will need a lot more details. Could be broken in a particular combination of things. What version of Unity do you use?