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