Addressable Sprite Atlases

Is there a way to ‘un-register’ an atlas with the SpriteAtlasManager?

In this crude example we load the sprite atlas when it is ‘requested’ by the engine.
This occurs when a sprite object is present in a scene that just loaded, as an example…

The problem is, when we unload the atlas, the next time the scene loads, and we want to re-load the atlas, the event SpriteAtlasManager.atlasRequested, doesn’t fire, because the engine has no way of knowing that we unloaded the atlas manually (to save memory), there isn’t a function or method of telling the SpriteAtlasManager that the atlas no longer exists, at least that I can find.

And unity is not unloading the atlas on it’s own. If you load the atlas this way in a scene with sprites, and then transition to an empty scene, the altases are all still in memory. Which is why I am unloading them manually.
Even if I call Resources.UnloadUnusedAssets(); the atlases are still there, so I call
Addressables.Release(nameOfAtlas); to ensure they get unloaded, but this doesn’t inform the SpriteAtlasManager that it’s gone, so the next time you go back to the original scene, it doesn’t ask to load the atlas…

private void Start()
{
    SpriteAtlasManager.atlasRequested += LoadAtlasRequestFromUnityEngine;
}

private void LoadAtlasRequestFromUnityEngine(string name, Action<SpriteAtlas> callback)
{
    AsyncOperationHandle op = Addressables.LoadAssetAsync<SpriteAtlas>(name);
    op.Completed += (AsyncOperationHandle handle) =>
    {
         if (handle.Status == AsyncOperationStatus.Failed)
         {
             //Handle fail
         }

         else if (handle.Status == AsyncOperationStatus.Succeeded)
         {
             successCallback((SpriteAtlas)handle.Result);
             // Do something with the atlas
         }
    };
}

Am I just missing some method somewhere?

doesn’t have anything…

Is there a way to get a Unity person to respond? Is that entirely based on what they happen to look at, or popularity of a thread or is there something else that needs to be done? I have also posted in Unity Answers, but haven’t heard anything yet…

By design, only the required Atlases are loaded through atlasRequested callback. By design unloading and reload/relink is not supported yet. Please take a look at :

for the dynamic behavior you are looking for. We are considering an API to unload Atlas through SpriteAtlasManager in the future. Will post an update.

I am already using SpriteAtlas.GetSprite()
So for now since there is no way to inform the SpriteAtlasManager of an unload, I will have to manually load all atlases myself, instead of relying on atlasRequested.

In terms of adding new functionality to inform the SpriteAtlasManager that an atlas was unloaded via code, is that something that would take a short amount of time to add, or are we talking like Unity 2020.2 or something longer term?

We will consider adding it after taking are of all possible scenarios for SpriteAtlas usage. We will also try to backport if possible. Will post an update to this thread. Thanks.

Any updates on this?

Any updates?

Any Update on that?
I am running into the same problem.

We refactored our game to lazy load all the sprite atlases doing the lazy binding with addressables. However the atlases doesn’t get unload on the Release calls.

An update on that would be great!

3 Likes