The part of the customizable game grid I am most proud of is the object spawner which can be attached to a Grid2DMono (or it’s singleton counterpart) to spawn objects in a variety of ways that are aligned to each grid point. To get a better understanding of how the object spawner works I would suggest watching the tutorial/walkthrough video earlier in this post. This is how the inspector looks for the object spawner:
As you can see, this is also a custom inspector utilizing the editor library I wrote specifically for the grid (but has also been used in Dream Walker for example). I have a lot of spawning modes, here is a list of them:
Utilizing these you can do a wide variety of things, from quickly making a chess board that can be scaled up procedurally to making maps that can have features that generates at a random grid point or a range of random grid points. You can also draw objects on the grid using either specified indices or specified coordinates to, for instance quickly make a maze etc.
This is easily my most advanced script because there is so many combinations to cover. I learned a lot about quaternion multiplication and other quaternion methods to handle all the rotational math. I also had to dig into the source code for Handles.Button to figure out how I could detect when the mouse is dragging over the button instead of just detecting a click. To make it work I had to copy most of the handles code and rewrite some of it and put it in the editor library.
I am very pleased with how the grid turned out, and I can say that I’ve learned a lot in the process. I have submitted it to the asset store for review, and if it gets accepted, it will be released there. I have high hopes.