If the positioning of objects needs to be restricted to specific increments, it is useful to have a grid drawn in the scene panel to help ensure that new objects are positioned based on those values, and also code to snap objects to that grid.
In this recipe, we'll use Gizmos to draw a grid with a customizable grid size, color, number of lines, and line length. The result of following this recipe will be as follows:
![](https://static.packt-cdn.com/products/9781788471909/graphics/assets/ca48e620-10dd-4f23-8869-30f6b9ec56b5.png)