Black lines between tile sprites

I have a tile engine I’ve built myself. Every tile on the screen is a game object with a SpriteRenderer. I set these renderers with sprites created using Sprite.Create(Texture2D, Rect, Vector2, float), passing a Sprite with all the map tiles as parameter.

It doesn’t matter what I do, I keep getting these weird 1px black lines between rows of tiles every now and then. How do I fix this? What’s causing it?

Additional info:

When I set the filter mode to Bilinear or Trilinear I get black lines between every row and column of tiles.

The lines I get with Point filtering keep blinking as I move around the map and only stay fixed when the camera is not moving. The ones I get using Bilinear or Trilinear filtering are static, even when I move around, although their width change a little.

Here is my project running on the web player:

https://dl.dropboxusercontent.com/u/1978232/Bin-Debug.html

You need to create a material, apply one of the default sprite shaders and then click “Snap To Pixel” checkbox. Use this material to render your sprite.

Turn on Pixel Snap in the Renderer Material of your object and turn of anti aliasing in Edit/Projectsettings/Quality

I had this same problem and changed the “Pixels to Units” size to a slightly smaller value, caused the line flickering to disappear.

This might explain at least some of the lines: Messy Alpha Problem - White around edges - Unity Answers

Try marking them as Static so Unity knows that they aren’t moving.

If you are using tile maps in 2017.2 or later you may come across this issue even with the above solutions (pixel snapping, etc…). I fixed this by changing the Grid layers cell gap size to -.05 on both the x and y axis.

alt text

Old question but I have a solution if you use Tiled2Unity !

Look in the Tiled2Unity > Materials folder in the project. Click on the spritesheets and then check “Pixel Snap” for all of this ones.