unity-game-engine2d

Unity camera grid


enter image description hereHow to fix this grid?

This appeared after adding cinemachine, I was able to fix it, but the objects moved back and forth when the camera moved, and I deleted cinemachine, but it remained, what should I do? Unity version 2021.3.28f1


Solution

  • This is a common issue in Unity, it happens when you have tiles made up of a source texture that doesn't have any padding around the individual tiles.

    You can either edit your source texture / tiles to add 1px of transparency, or add all your tiles to a Sprite Atlas which will do that for you:

    1. Right Click > 2D > Sprite Atlas
    2. In the new Sprite Atlas' inspector, add your images to the "Objects for Packing" array

    Do note that using a Sprite Atlas will change the UVs for your tiles: if you use your own shader that expects each tile to have certain UVs, a shader atlas might break that.