Search Unity

Change address of the sprite in atlas

Discussion in 'Addressables' started by dotsquid, Jun 30, 2020.

  1. dotsquid

    dotsquid

    Joined:
    Aug 11, 2016
    Posts:
    224
    Is it possible to change the address of the sprite in the atlas? I tried doing this in a custom AnalyzeRule to fix duplicated addresses. But it seems it's not possible, because I can't change that address even manually inside Editor?
     
  2. dlegare-synapse

    dlegare-synapse

    Joined:
    Jan 17, 2018
    Posts:
    54
    Currently, it's not possible (as far as I know). Right now the way you load a sprite from a sprite atlas with Addressables is to use subobject key syntax. So for example, if you have a sprite atlas with the address "my_atlas" and it contains a sprite named "my_sprite", you could load it with the key "my_atlas[my_sprite]":

    Code (CSharp):
    1. Addressables.LoadAssetAsync<Sprite>("my_atlas[my_sprite]");
    However, you can't mark the sprite itself as addressable, only the atlas, which means you can't give the sprite a unique name :( Well, you technically can also mark the sprite as addressable and give it its own address, but right now there's a bug that prevents you from being able to actually load that sprite at runtime.
     
    dotsquid likes this.