Search Unity

Is Sprite Atlas used automatically?

Discussion in '2D' started by VoodooDetective, Jul 1, 2020.

  1. VoodooDetective

    VoodooDetective

    Joined:
    Oct 11, 2019
    Posts:
    239
    I've created a sprite atlas, but it seems like the only way to use it is through code. It made me wonder if sprites that are assigned to an atlas are automatically loaded from the atlas even though I set the sprite renderer directly from the individual sprite.

    How else would you use the sprite atlas? Only through code?
     
  2. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,514
    Yes, Unity takes care of making the sprites available to the SpriteRenderer automatically when assigned (in the inspector, or via code). When handling individual sprites, you're supposed to not need to think too hard about where it's coming from, whether it's an individual sprite, a sprite in a spritesheet with Multiple mode, or a Sprite Atlas. That isn't to say there aren't things to consider, like whether two sprites are likely to share the same batch / draw call, and similarly whether sprite 'X' and sprite 'Y' should be combined into the same Sprite Atlas, but that's not your worry here. There are some caveats that don't apply to your case, like when doing fancy loading or late binding, but worry about that when you need to.
     
    sarebots2 and VoodooDetective like this.
  3. VoodooDetective

    VoodooDetective

    Joined:
    Oct 11, 2019
    Posts:
    239
    Thanks, that answers the question perfectly!