Search Unity

Sprite Atlas + Ruletile + Tilemap

Discussion in '2D' started by RossAlexander, Apr 22, 2020.

  1. RossAlexander

    RossAlexander

    Joined:
    Mar 3, 2016
    Posts:
    2
    Hello all,

    tl;dr: Is it possible to use a sprite atlas with a Rule Tile (2D Tilemap Extras) for use with a Tile Palette?

    I made a sprite sheet that has a bunch of 16x16 sprites, one right after another, with no gaps. I imported and sliced it with the Sprite Editor in Unity. When I use these with Unity's RuleTile (2D Tilemap Extras) and a Tilemap, I get black lines between some of the tiles. I've read that this is caused by the editor/engine rendering a tiny bit beyond some of my sprites in my spritesheet, so I'm seeing just a tiny bit beyond the 16x16 bounds of the sprite.

    I'm using no filter (point), no anti-aliasing, and no compression.

    The suggested solution, which sounds correct, is to pack my sprites into a sprite atlas, as this will add padding beyond the individual sprites (i.e., expand the edge of the sprite with the same pixels that make up the edge).

    I've packed my sprites into an atlas, but don't seem to have any way of using the atlas in a ruletile/tilemap. When it comes time to load sprites into a ruletile/tilemap, I can only seem to choose the individual sprites that I used to make the atlas, but not actually use the atlas itself.

    Any ideas? Thanks!

    Unity 2019.3.5.f1
    2D Sprite 1.0.0
    2D Tilemap Editor 1.0.0
    2d Tilemap Extras Preview 1.5.0
    Universal RP 7.1.8
     
  2. brigas

    brigas

    Joined:
    Oct 4, 2014
    Posts:
    522
    If you have the sprites in the atlas you can use them as normal and they will be coming from the atlas, did you test if the gaps were fixed after creating the atlas? padding = 2 should be enough

    You can also create the padding yourself in your image editor, make the sprites as 18x18, copy the color of the edges of your tiles in the extra space and then when you import the sprite sheet to unity slice it as 16x16 tiles, dont include the padding in your slices.
     
  3. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    If you are using the Unity Sprite Atlas and assigning the individual Sprites to the Sprite Atlas, when in Play Mode or in a built player with the Sprite Atlas, the TilemapRenderer with these Sprites (whether they have been assigned to a normal Tile, RuleTile or other scripted Tile) will make use of the Sprite Atlas.
     
  4. RossAlexander

    RossAlexander

    Joined:
    Mar 3, 2016
    Posts:
    2
    Thanks so much, @brigas and @ChuanXin - The ruletile does seem to be using the sprite atlas.

    What threw me off was that the Game window in the editor still shows the lines when not in play mode. However, the line-problem seems to have been solved (atlas being utilized) when in play mode. I guess I was not expecting such automated utilization of the atlas, and thought I had to manually make use of it. Anyway, thanks for the help!
     
  5. rubendariohh

    rubendariohh

    Joined:
    Oct 14, 2017
    Posts:
    32
    Hi, how you packed the Sprite sheet into an Atlas? I know how to pack individual sprites into an Atlas, but how to do it for a Sprite sheet? Thanks!
     
  6. ChuanXin

    ChuanXin

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    1,068
    You can add your Spritesheet Texture to the Objects for Packing in the Sprite Atlas: https://docs.unity3d.com/Manual/SpriteAtlasWorkflow.html
     
  7. Hookkshot

    Hookkshot

    Joined:
    Jan 11, 2013
    Posts:
    27
    upload_2022-2-10_9-46-46.png
    Using Unity 2020.3.16

    Still get tilemap tearing.

    upload_2022-2-10_9-47-32.png

    Really at a loss of what to do. I feel like it should just work.
     
  8. Hookkshot

    Hookkshot

    Joined:
    Jan 11, 2013
    Posts:
    27
    upload_2022-2-10_9-54-11.png
    In Unity

    upload_2022-2-10_9-54-25.png
    In Image editor

    It seems unity is blurring the pixels and bringing that over into the sprite atlas. Causing the tearing.

    I have taken compression off all images and it still does it.