Hello Guest

Author Topic: Atlas 2x textures in MeshRenderer loading with scene  (Read 3420 times)

int64

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Atlas 2x textures in MeshRenderer loading with scene
« on: August 14, 2013, 06:51:23 am »
As far as i know, unity at scene loading loads all resources (textures, materials, audioclips, e.t.c.) that has been assigned to script's fields in inspector (all serialized fields). Selecting a sprite in tk2dsprite component on gameobject automatically sets material/atlas texture to its MeshRenderer material. If at sprite selecting time tk2dsystem.currentPlatform is 2x it sets a large atlas texture, and that texture will be loaded with scene loading automatically because it has reference in scene. The first way is setting tk2dSprites with selected 1x platform in editor: at scene loading only 1x textures will be loaded by default, but in short period of time in memory can be loaded both 1x and 2x textures and it may cause a didRecieveMemoryWarning on devices with 2x platform settings. Second way is setting all tk2dSprite's MeshRenderer materials to none and resave scene - then scene has no references to atlases. Is it right?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Atlas 2x textures in MeshRenderer loading with scene
« Reply #1 on: August 14, 2013, 12:05:19 pm »
Thats almost correct. Except what you're seeing is a bug in Unity.
The material that is used in Unity is marked as DontSave, so it should not save the reference to the material (it doesn't) or the texture (it incorrectly does). Unity has acknowledged the bug, but I don't know what the current state is.

Anyway, there is a workaround for this.

Create a file named tk2dOverrideBuildMaterial in the project root outside Assets before you start the build, and delete it after your build is complete.
It should be in:

tk2dOverrideBuildMaterial
Assets/
Libraries/
ProjectSettings/

Then create your build. You can remove it after your build is complete.

int64

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Atlas 2x textures in MeshRenderer loading with scene
« Reply #2 on: August 15, 2013, 06:45:37 am »
Thanks a lot, it works! :)