Author Topic: Could widgets be caching a hard reference to atlas texture?  (Read 9438 times)

Marcin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Could widgets be caching a hard reference to atlas texture?
« Reply #15 on: September 24, 2015, 07:47:28 AM »
A important thing that I did't notice before. AtlasReplacement script must hold the reference for all loaded resources and use DontDestroyOnLoad. If not, the unity3d could clean up during a scene transiction.
But that way all atlases are loaded into memory at all times.
I would like to have only atlases that are used on the current scene loaded into memory.
Is there a way to not lose the reference to SD/HD atlas in the reference atlas?

I have all - SD, HD and reference atlases prefabs in the Resources folder.
At app launch Im loading all reference atlases and setting the reference to SD or HD atlas (that I also load from Resources).
At first scene everything is ok, but after going to different scene I have default (SD) atlases referenced (default setting in the reference atlases) - as if the reference to HD wasnt remembered. It makes sense but some time ago (few versions of Unity ago) it worked fine.

Do I have to load all atlases and set HD references on each scene change?
I think in the end it would mean the same thing as having all atlases loaded all the time.


Regards, Marcin.


EDIT:
Im doing just that - loading all reference atlases and setting HD atlas if needed.
Its fine because its just prefab references, texture of the atlas is not loaded.
And then - on newly loaded scene - only if particular reference atlas is used the texture (SD or HD) will be loaded.
I think its how it should be.
What You think?
« Last Edit: September 24, 2015, 08:25:50 AM by Marcin »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Could widgets be caching a hard reference to atlas texture?
« Reply #16 on: September 26, 2015, 04:44:03 PM »
It doesn't make sense to keep references at all times. Simply load them as needed.
  1. if (!someAtlas) someAtlas = Resources.Load(...);