Search Unity

New Sprite Atlas + UI?

Discussion in 'UGUI & TextMesh Pro' started by TimHeijden2, Sep 5, 2017.

  1. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    So in 2017.1 a new feature was released by Unity, the Sprite Atlas:
    https://docs.unity3d.com/Manual/SpriteAtlas.html

    In addition, the Sprite Packer is now marked as "Legacy" in the project settings --> editor settings.

    In NGUI, you could also create atlases. Then, you would create a UISprite component and directly reference an image inside the atlas. There does not seem to be any component like this in Unity UI!

    It seems like a core feature that the atlas needs, ESPECIALLY because Unity marked the old system as Legacy, which basically means it will be deprecated and then removed in the future.

    Am I missing something obvious, or is the sprite atlas feature basically experimental / not finished?
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Sprites in the sprite atlas are referenced just like normal sprites in the ui or in a sprite object. Drag the sprite from the folder, into the sprite field. It automatically sets up the referencing either before play or during building depending on your settings. Which works the same way as the old Sprite Packer.

    Tested it with a project I have not packed. Went from 50-180 set pass calls to 12-19. Dragged the sprites into the list for the sprite atlas and pressed play, works really well and was super easy.
     
    Nodrap and TanshaydarGames like this.
  3. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    Thanks Chris, I understand how it works now. My initial confusion was about how unity's sprite / image component would know to use the atlas. It appears there is code in place for this so yay :)

    It would be awesome if you could see the atlases a sprite will be packed in from the inspector of that sprite!
     
  4. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Should be a "Pack Preview" button after adding sprites, as long as its enabled in the editor settings. This really does create the atlas and it can be viewed in the thumbnail and in the inspector preview.
     
    TanshaydarGames likes this.
  5. TimHeijden2

    TimHeijden2

    Joined:
    Aug 11, 2016
    Posts:
    86
    What I mean is a link from the Sprite inspector TO the atlas(ses) such that you know when looking at an asset that it will be handled by the atlas.
     
  6. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Yeah the whole magic thing kinda is counter intuitive. The old way at least you knew it was apart of one with the packing tag, but you still didn't get a link to that either.

    The way I have set it up right now is to use folders in the SpriteAtlas instead of the individual sprites, that way if I add anything to the folders it gets added automatically to the atlas. So I know which folder is used for which atlas, and I know it will be packed.
     
    TanshaydarGames likes this.