Search Unity

[Unity Pro] Are UI sprites atlassed automatically with SpritePacker

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by mr_zog, Feb 18, 2016.

  1. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    I am somewhat unclear about the current state. If you do some searching, you find many theories, and most of them are quite old.

    My questions are:
    1) Are sprites used in Unity UI automatically packed into an atlas?
    Sprite Packer in the Editor Settings is set to "Always enabled".
    I don't see anything in "Project\Library\AtlasCache", as the docs state.

    2) Will it affect anything, if I use Sprite Packer for UI or is this for "normal" 2D elements?

    3) My observation is, that you can only generate an Atlas with Sprite Packer IF you assign a tag to the sprite.
    No tag = no packing. Which is sort of stated on the docs. Can somebody confirm this?
    Is this also true for UI?


    Thanks!


    PS: Link to the official docs:
    http://docs.unity3d.com/Manual/SpritePacker.html
     
  2. Teravisor

    Teravisor

    Joined:
    Dec 29, 2014
    Posts:
    654
    1. It should if Sprites have Packing Tag set. You can manually see it if you open Window->Sprite Packer and click Pack (it should still pack even if you don't do that when you build/run solution).
    2. It will affect amount of drawcalls UI takes. With atlas it'll take less drawcalls meaning better performance. With all sprites being on different textures, it'll need to change texture resulting in SetPass calls (if you're using Unity 5+ you will see Batches and SetPass calls, if you're using 4 or before you'll see DrawCalls which are essentially same as Batches+SetPass). Also there should be UI batching as well.
    3. Yes. It's also true for UI as it uses same sprites. Without packing tag Unity won't know which atlas to put this sprite into.
     
    Last edited: Feb 18, 2016
  3. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    Thanks for the answer, it's good to know that no internal atlasing is done, even though I mistakenly assumed it for UI (not sure why, but I think I read that somewhere).

    So I guess the way to go is: always set a tag or tags for UI sprites.