How to generate a grid for procedurally generated platforms

I am attempting to create a number of procedurally generated floating platforms which can have a number of objects placed on top of them, and want to use a grid-based system for doing so, however, I have no idea how to go about generating said grid to vaguely represent the following image.

As shown I want to get a grid that prevents objects being spawned too close to the edge so that they don’t overhang.

In you scene, create empty GameObjects at the center of each square in the grid, at the exact position that you want to spawn your objects. Let’s call these empty GameObjects Spawn Points, and we’ll just use their transforms as reference for spawning the objects. So, for ease of use rename each empty GameObject as “SpawnPoint”.

Also for ease of use, create another empty GameObject in the scene and rename it something like “GridRoot”. Then select all SpawnPoint GameObjects and drag-n-drop them to the GridRoot GameObject.

There are many different ways that you can use the above Transforms, so I’ll just give an example bellow.

Create a C# script and name it something like “Grid”.

In this script declare a List:

public List<Transform> SpawnPointTransforms;

Now, add the Grid component (script) to the GridRoot GameObject.

In the Inspector set the size of the List to, say 46, per your example image, and drag-n-drop each SpawnPoin GameObject to corresponding List elements in the Inspector.

After the above is set up, you can drag-n-drop the GridRoot GameObject to your Platform GameObject, and make it its child. Adjust the position of GridRoot so that it aligns with the Platform as you want it.

Finally, create a prefab of the complete Platform, so that you can reuse it as necessary.

The are many possible ways of using this, but the above gives you as starting point for laying out the spawn points and getting access to them in script.