I was doing some work on a Mystery Dungeon-like game, with procedurally generated meshes and a grid-based movement system.
I needed to check whether my controller was using the correct cell and whether my character mesh was positioned appropriately so I tried to check using a play-mode grid.
Unity doesn’t offer a grid visualizer for play mode in Editor so you have to use your own system. There are 3 main possibilities:
Replace your ground material with a debug grid-material
Write a shader
In my case I decided to go with Gizmos since I was only interested with editor play-mode.
The logic is simple: create a monobehaviour and add a OnDrawGizmos function. You can also add this function to any other monobehaviour in your scene if you want to. Then, we’ll just iterate and draw lines in a grid format.