UGTK cat mascotUGTKengine within an engine Request access

UGTK / Toolkit / Gameplay Systems / Grid System Completed

Gameplay Systems — UGTK

Grid System

Summary

The Grid System allow to instanciate and manage gameobject placed in a 2D or 3D grid layout.


Content


Modules Dependencies

None. The assembly definition used to reference UtilitySystems/GraphSystem, but no source file in this module ever used a type from it: the reference only forced you to keep a module you were not using. It has been removed.


Setup

Start from one of the two root prefabs rather than building the hierarchy by hand:

  1. 2DRootGrid for a grid on a Canvas, with GridCell2D_10_10 or GridCell2D_100_100 as the cell depending on the size you want.
  2. 3DRootGrid for a grid in the world, with 3DCellGrid as the cell.

Set the number of rows and columns and press BuildGrid(). Cells are instantiated from the prefab, so anything you change on the prefab applies to the whole grid.

Decide the cell size before building rather than after: rebuilding discards the cells and creates them again, so anything you attached to a cell by hand is lost.


How To Use

  1. 2D grid, place component to UI gameobject, set prefab and set grid size.

  1. 3D grid, place component to gameobject, set prefab and set grid size.


Testing Scene

Open GridScene in the module's Debug/ folder. It holds two grids: 2DRootGrid under the Canvas, whose cells are UI images, and 3DRootGrid at the root, whose cells are objects in the world. The GIF is the 2D one, because that is the one the Game view shows.

What to do, in order:

Select Canvas > 2DRootGrid. The scene ships with a 30 x 17 grid of 10 px cells, which is a wall of dots: set Grid Scale to 6 and give yourself a readable size first.

  1. Change Rows and Columns. With Auto Build On Start on, the grid rebuilds as you type, with the editor stopped - no button to press.
  2. Use + Row, - Row, + Column, - Column in the Excellence Controls block for the same thing one step at a time.
  3. Change Padding or Grid Scale and watch the layout redistribute.
  4. Build a grid far larger than the one on screen.

Step 4 is worth doing once: a grid built as individual objects stops being free somewhere in the hundreds of cells, and it is better to find that threshold now than in a level that ships.


Technical Info

The following are the main scripts and workflow of the Grid System:

Scripts:


© 2026 Marcello De Bonis. All rights reserved