How would I make a grid in Unity? I am planning on making a grid based level designer for anyone to use and enjoy they’re own levels, and to share with others. I am aware that I can pay for Grid Framework, but isn’t there a way to code a grid into the game?
Well if your talking about a simple 4x4 grid or bigger/smaller its quite simple really. You need to use nested for loops and instantiate a “grid piece” each time the loop completes.
// class members
public Transform gridPrefab;
int row = 4;
int col = 4;
// some function that builds the grid
for (int r = 0; r < row; r++)
{
for (int c = 0; c < col; c++)
{
Instantiate (gridPrefab, new Vector3(row, 0, col), Quaternion.Identity) as Transform;
}
}
NOTE: this is in C# which I prefer to code with.