I’m having trouble reloading Sprite Atlases from Asset Bundles after they have already been loaded once.
I have a pretty heavy 2D game, with a lot of large sprites, so I would like to load them in and out of memory as you progress through different parts of the game. I’m trying to use Asset Bundles containing Sprite Atlases to achieve this, but I have a problem when I want to reload a Sprite Atlas that I had loaded previously.
Steps to reproduce my problem:
-
Subscribe to
SpriteAtlasManager.atlasRequested
for late binding of Sprite Atlases -
When
atlasRequested
is called, load the requested a Sprite Atlas from an Asset Bundle. This works fine. -
Now unload the Asset Bundle that was just loaded. The Sprite Atlas is unloaded with is and sprites disappear from the scene in Unity.
-
Now, how do I reload and rebind the Sprite Atlas? Can I somehow force the
SpriteAtlasManager
to callatlasRequested
again?
Does this make sense? Is it the right strategy to solving my problem? Any thoughts?
**EDIT: I have had a look at this, which I think is doing what I want to do, but it seems like a pretty convoluted way to achieve something like this: GitHub - jconstable/SpriteSleeper: For Unity applications that run on low-memory devices (mobile, mostly), allowing for UGUI hierarchies to remain in memory, without paying the memory cost for their SpriteAtlases. Built for Unity 2017.1+ and the new AtlasPacker system. **