This is a Unity-based 3D grid system that allows users to create a customizable grid and place objects within it. The system supports both runtime grid placement and editor-based object placement, with a helpful converter script to transform meshes into the proper prefabs for easy placement on the grid.
- Customizable 3D Grid: Create grids of various sizes and cell dimensions.
- Mesh to Prefab Converter: A script to convert meshes into prefabs suitable for grid placement.
- Editor Support: Place objects in the grid directly in the Unity Editor for easier testing and design.
- Grid Object Placement: Easily place objects on the grid with snap functionality for better alignment.
- Download or clone this repository to your local machine.
- Open the project in Unity.
- The system is set up to work directly within the Unity Editor, with all the necessary scripts and prefabs included.
- Ensure that the Editor folder is set up in your project for editor-only scripts.
-
Create a Grid: You can create a grid in the Unity scene by dragging the
GridController
prefab into the scene. This will create a default grid of configurable size. -
Grid Settings: In the Inspector, you can modify grid settings such as the number of rows, columns, and the size of each cell.
-
Object Placement: You can place objects on the grid by using a helpful Editor placing script, using scripts to automate object placement during runtime or placing them using the mouse in runtime.
- Prepare Mesh: Import a 3D mesh into your Unity project.
- Convert the Mesh: Go to Tools > Harmony Grid System > Convert Objects. Fill in the required setting or leave as default and the converter script will take the mesh and convert it into a prefab that is ready to be placed on the grid.
- Prefab Placement: Once converted, the prefab can be placed on the grid just like any other object.
- Create Grid: Drag the
GridController
into your scene to generate a new grid. - Prepare Mesh: Import any mesh you want to use.
- Convert to Prefab: Use the mesh converter to turn your mesh into a prefab.
- Place Prefabs: Drag the newly created prefab into the scene and place it onto the grid.
You can customize the grid's size, shape, and placement functionality by modifying the GridManager
and other related scripts. The system is flexible and allows for easy integration into different game types or scenes.
This project is licensed under the MIT License – see the LICENSE file for details.
- Inspired by grid-based game mechanics.
- Thanks to the Unity community for their continuous support and tutorials.
- Big thanks to CodeMonkey and his amazing video series Grid System in Unity of which this takes heavy inspiration from.