
Region Grid System with Persistent Spawns + Integrated Save (Unity)
A downloadable asset pack
Terrain-Based Region Grid System – Persistent Spawning + Save Integration
Take full control of your open-world experience with a powerful, editor-integrated region grid system designed specifically for terrain-based Unity projects.
This asset delivers a fully visual, customizable zone grid, allowing you to define territories like Forest, Valley, Beach, or Mountain, and associate persistent spawning logic to each. Everything is automatically saved and restored, making your world feel truly alive — without the typical headaches of managing thousands of objects.
Perfect for open-world, survival, simulation, and collectible games.
What’s Included
• Advanced Region Grid System
Divide your terrain into a scalable grid where each cell can be assigned a unique zone type. Modify directly in the Unity editor with real-time gizmos and serialization support.
• Persistent Natural Spawner
Spawn objects per region type, and automatically repopulate them at the exact same positions after loading. No manual setup — just drop and go.
• Optimized Save System (JSON)
Lightweight, readable, and modular save/load system that keeps only what matters. Extend easily to support your own data.
• Distance-Based Instance Control
Objects are only instantiated when close to the player — allowing massive world scale (tested with 100,000+ saved positions) without high memory usage.
• Save Button Script
Includes ready-to-use UI logic to trigger saves manually — perfect for menus or debug tools.
• Simple Movement Script
Comes with a basic player movement controller for immediate testing and integration.
• Commented and Expandable Code
Every script is written cleanly, with comments and modular structure. Add your own zone types, logic, or data in minutes.
New
- Basic collection system ready for future modifications. You don’t need to modify the main code to add the material collection system anymore.
Why This System Stands Out
• Fully visual setup – No guesswork: you see and edit your zones right on the terrain in real-time.
• Dynamic, persistent object control – Objects aren't just saved; they're respawned precisely and intelligently.
• Efficient for huge worlds – The system doesn't bloat your memory, even with 100k+ instances.
• Separation of territories – Since spawns are tied to specific region types, you can easily split your world into controlled ecosystems.
• Robust cell management – Grid cells are serialized, reliable, and resistant to data loss — your world state is preserved exactly.
• Expandable zone system – Want more zones? Add new types to the enum, and you're good to go. The system is built to grow with your project.
• Perfect for procedural generation or structured placement – Whether you're placing trees, enemies, resources, or collectibles, the grid helps you organize them by context.
Use Cases:
• Survival games with distinct biomes and respawn rules
• Farming sims with regional spawning of crops or fauna
• Open-world adventures with memory-efficient object tracking
• Crafting and exploration games with zone-based item distribution
• Educational or visualization apps needing spatial mapping
Ready to bring logic and life to your massive Unity terrain?
This system does the heavy lifting — you focus on creating.
How to Use
1. Terrain Setup
-
Create a Terrain in Unity (GameObject > 3D Object > Terrain).
-
The region grid is built directly on top of this terrain.
2. Adding the Region Grid
-
On the terrain GameObject, add the
grade_regioes_mundo.cs
script. -
It will automatically generate a grid using the terrain size and cell size (
tamanhoCelula
, default 50). -
Each cell gets a zone type (Valley, Forest, etc.) and is serialized/stored automatically.
Tip: Zones can be set via the Inspector or through code using DefinirZona(pos, tipo)
.
3. Creating the Instance Manager
-
Create an empty GameObject in the scene, e.g., named
GerenciadorNaturais
. -
Add the
ControlePopulacaoNaturais.cs
script to it. -
In the Inspector, configure:
-
Name for each natural object type (e.g., "Tree", "Rock")
-
Prefab to spawn
-
Target zone type (e.g., Forest)
-
Desired quantity to populate
-
Spawn Y position (
posicaoY
) if needed
-
On game start, it generates valid positions within the target zones and spawns objects dynamically based on player distance.
4. Saving and Loading
-
Position data is auto-loaded at runtime and can be saved with:
-
SalvarPosicoesNaturais()
orSalvarPopulacao()
-
-
To create a save button, use
SalvarBotao.cs
on a UI Button — it handles saving viaGerenciadorSaveGeral.Salvar()
.
5. Testing
-
Use
jogador_movimento.cs
to move any GameObject tagged"Player"
(required for proximity-based spawning). -
Walk around and see objects spawn in/out of view based on distance.
6. Expanding
-
Want more zones? Simply add to the
TipoZona
enum ingrade_regioes_mundo.cs
. -
The system will automatically support them, both in editor and in code.
-
To add new natural object types, just update the list in
ControlePopulacaoNaturais
via Inspector.
About Grid Generation
The system automatically detects the terrain's total size and calculates the number of grid cells based on the default tamanhoCelula
(50).
Example:
A terrain with 5,000 x 5,000 units, using a cell size of 50, will generate:
100 x 100 cells (total of 10,000 cells)
You can change the cell size in the tamanhoCelula
field before attaching the script to the terrain, to control zone density and region size.
Note: Cells are used only during edit mode for visual setup.
They do not impact runtime performance, and are excluded from the final build memory.
Updates
1.1 - Bug Fixesㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ | Fixed the object respawn issue in ControlePopulacaoNaturais, where due to Unity's processing, objects were being respawned at the same previous position. Added logs to track the exact respawn locations. The spawn distance now respects a minimum distance from the player. |
2.0 - Additions and Bug Fixes | General adjustment to fix coordinate duplication issues that persisted even after the 1.1 bug fixes. Added a base script for collecting instantiated objects; these are optional and provide only basic functionality to be modified later. |
3.0 - Grid Control & Terrain Resize | Added toggle for enabling/disabling the grid to allow terrain editing without complications. Also included a refresh feature that recalculates the terrain size to fit the cells when their size is changed. When adjusting these settings, it’s recommended to create a backup copy. Now the cells respect the terrain height, and instantiated objects are spawned at the correct terrain elevation. |
Purchase
In order to download this asset pack you must purchase it at or above the minimum price of $9 USD. You will get access to the following files:
Leave a comment
Log in with itch.io to leave a comment.