Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to know the reference count of a Sprite Atlas?

Discussion in '2D' started by qiu_lirui, Dec 6, 2018.

  1. qiu_lirui

    qiu_lirui

    Joined:
    Oct 28, 2017
    Posts:
    4
    Hi, I'm using SpriteAtlas + AssetBundle (late binding).

    But I'm confused about When to unload the AssetBundle. The parent AssetBundle shouldn't be unloaded until the SpriteAtlas becomes unwanted. But there seems no API or CALLBACK telling the SpriteAtlas is unwanted.

    Some good ideas to unload the AssetBundles containing SpriteAtlas? Thank you.
     
    Last edited: Dec 12, 2018
  2. AnthonyReddan

    AnthonyReddan

    Joined:
    Feb 27, 2018
    Posts:
    39
    Hi there, did you figure this out? I'm trying to do the same.
     
  3. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    619
    One way to do that is to check all active sprites in the screen and check if they are referencing textures from SpriteAtlas (SpriteAtlas textures do have the Atlas name embedded in their names)

    Since SpriteAtlas can be loaded dynamically and multiple SpriteAtlas can exist that include same Sprites, there is no explicit API to provide that count yet. But we will consider adding it in the future.