Unity 2D tiles and grid

I am currently working on my first Unity project, which is a 2D strategic RPG (similar to Fire Emblem).

The tile system I developed works pretty well but now I am stuck on overlaying it with a grid.

I modified the code found in this thread and it works pretty well, however now the problem is, that the lines drawn with GL.Vertex3 are drawn above everything but the GUI.

This is a problem since I wanted to have 3 sorting layers (from background to foreground): terrain, grid, units. Units can be bigger than a tile, which leads to a problem when the grid overlaps the unit :(.

Is there a way to draw the lines with GL in a specific sorting layer? Is there another good way to draw a grid?

Thanks in advance!

Did you use MeshTopology.Lines? If so, the lines should always be one pixel wide. If not, try that - it’s a parameter to Mesh.SetIndices.