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. Dismiss Notice

Sprite atlas basic question

Discussion in '2D' started by y4m0, Jul 30, 2022.

  1. y4m0

    y4m0

    Joined:
    Jan 6, 2016
    Posts:
    10
    Hello everyone,

    I'm not totally sure I understand how sprite atlases work in Unity, so I'd like to get a confirmation from you.

    I proceed as follows:
    - For the purpose of my UI, I create a series of separate sprites, each from a different image
    - I use the corresponding sprites into my UI
    - Then I create a sprite atlas to gather all these sprites (after enabling the Sprite Packer in the Project Settings)

    My question is: is this procedure enough for Unity to use the sprites from the atlas instead of the original sprites?
    I ask this because when I run the project and look at the properties of the sprites used ingame, Unity always shows me the original sprite as Source Image, not the atlas sprite.

    Maybe I misunderstood or forgot something.

    How do you get sure Unity uses the atlas sprites instead of the original ones ?

    Thank you in advance for your help.
     
  2. rarac

    rarac

    Joined:
    Feb 14, 2021
    Posts:
    570
    if you open the stats window you will see less draw calls if the sprite atlas is being used correctly
     
  3. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    The steps you described look correct.

    Some additional techniques you can use to test if texture atlas are working and draw calls are batched togehter:
    * Sprite.Texture field. According to docs it should point to atlas texture if it's being used. https://docs.unity3d.com/ScriptReference/Sprite-texture.html
    * Unity builtin frame debugger this should not only give you information of what texture get's used but also other reasons why draw calls aren't batched. https://docs.unity3d.com/Manual/FrameDebugger.html
    * External frame debugging tools like RenderDoc which can be used with standalone builds of your game.