A comprehensive guide to the DT.GridSystem โ a generic Unity grid framework supporting both 2D
(XY) and 3D (XZ) layouts.
This manual covers architecture, usage, and function-by-function documentation with clarity.
Welcome to DT.GridSystem, a flexible and extensible system for managing 2D and 3D grids in Unity.
๐ง Use Cases:
Turn-based tile games, AI navigation maps, level editors, placement systems, and more.
GridSystem<T>
)DT.GridSystem is structured into 3 clean layers:
Layer | Responsibility |
---|---|
Storage | Holds a 2D array of TGridObject |
Conversion | Grid โ World position translation |
Utilities | Snapping, debug visualization, events |
graph TD;
A[GridSystem<T>] --> B[GridSystem2D<T>]
A --> C[GridSystem3D<T>]
B --> D[Your2DGridScript]
C --> E[Your3DGridScript]
Window โ Package Manager
.https://github.com/RahulLinganagoudra/com.dreamertheory.gridsystem.git
Click Add and Unity will install the package automatically.
โ๏ธ Make sure your repo has apackage.json
in the root or underPackages/DT.GridSystem
.
git clone https://github.com/RahulLinganagoudra/com.dreamertheory.gridsystem.git
Copy the DT.GridSystem folder into your Unity projectโs Assets
directory.
TGridObject[,] gridArray = new TGridObject[width, height];
Awake()
CreateGridObject(...)
per cellAddGridObject(int x, int y, T value)
RemoveGridObject(int x, int y)
GetGridObject(int x, int y)
GetGridObject(Vector3 worldPos)
TryGetGridObject(...)
for safe retrievalGetWorldPosition(int x, int y)
GetGridPosition(Vector3 worldPos)
OnDrawGizmos()
drawGizmos
to controlUnityEvent OnGridUpdated
Fired on any grid update.
DT.GridSystem
to your projectGridSystem2D<T>
or GridSystem3D<T>
protected override T CreateGridObject(GridSystem<T> grid, int x, int y)
Class | Purpose |
---|---|
GridSystem<T> |
Abstract base for all grids |
GridSystem2D<T> |
2D implementation |
GridSystem3D<T> |
3D implementation |
MIT License โ Free to use, modify, and distribute.
Pull requests and attribution are welcome but not required.