Skip to content

Dungeon Crawler Framework — Dungeon Generator

Overview

The Dungeon Generator is one of the core tools in Dungeon Crawler Framework. You open it from Unity's top menu under Window → CrawlerKit → Dungeon Generator. It runs entirely inside the editor and has zero impact on game performance — all it does is generate a scene and bake everything into a single JSON file, which the runtime loads when the level starts.

In one sentence: it generates a dungeon procedurally, lets you edit it by hand, and then exports it to a JSON file your game uses at runtime.

The window is built from stackable panels. Each panel header has two small arrows (▲ and ▼) that let you drag panels up and down into whatever order suits your workflow; the order is remembered between Unity sessions. The four content libraries (doors, traps, secret walls and chests) can each be collapsed when you are not using them.


Preset

The first panel is Preset — a list of ready-made generator templates:

  • GrimrockCorridors — 30×30 map, small rooms, high BSP depth. Tight, twisting corridors in classic Legend of Grimrock style.
  • OpenRooms — 25×25 map, large open rooms, minimal splits. Throne rooms and grand crypts.
  • SmallMaze — 20×20 map in Maze mode. Pure labyrinthine corridors, no rooms.
  • TinyArena — 10×10 map, a single large room. Ideal for boss fights or arena encounters.
  • BigLabyrinth — 50×50 map in Maze mode. The largest possible labyrinth.
  • Custom — you set everything yourself.

Selecting a preset updates the sliders below automatically. You can still tweak any slider afterwards — the generator switches itself to Custom so you always know when you have drifted from a template. You can also save a preset to a dedicated folder and load it back later.

Two generation modes are available. BSP (Binary Space Partitioning) divides the space into sections, places rooms inside them and connects them with corridors, producing structured, navigable layouts that feel like a classic dungeon crawler. Maze mode produces a traditional labyrinth with a single path to any destination.

Note that what you see at this stage is not yet a finished dungeon — it is a visualisation of "Flags", markers that will later be used to build walls, floors and everything else from your own prefabs.


Layout Snapshot

Just below the presets, the Layout Snapshot panel lets you save and restore a layout. When you have a layout you like, click Save: the generator asks for a filename and writes the full state of every grid flag to a JSON file in your project — positions, cell types, which walls are open or closed, stair directions, everything.

To return to it, pick the snapshot from the dropdown and click Load. The generator clears the current flags and reconstructs the saved layout tile by tile. Crucially, it does not touch your prefabs — walls, floors, doors and chests stay exactly where they are. Snapshots operate only on grid logic, so you can keep several variants of the same level and switch between them instantly.


Map

The Map panel configures the dungeon size and algorithm.

Width and Height set the map dimensions in tiles (8 to 50). A 15×15 map is a solid starting point for a small level.

Generator Mode offers two options. In BSP mode three extra sliders appear: Min Room Size, Max Room Size and BSP Depth (how many times the map is divided — more splits means more, smaller rooms and longer corridors). In Maze mode a recursive backtracker produces 1-tile-wide corridors with no dead ends, and the BSP sliders disappear because they aren't needed.

Settings are validated on the fly. If you enter a room size larger than the map you'll see a red error and the Generate button locks, so you can't generate something impossible.


Seed

The Seed panel controls randomness. Random Seed is enabled by default — every Generate produces a different layout, and the seed used is logged to the console so you can note it down. Uncheck it to enter a Fixed Seed: a specific number that reproduces the exact same layout every time, useful for testing or recreating a particular map.


Prefabs

The Prefabs panel is where you hook up your graphics. Four slots — Wall Prefab, Floor Prefab, Stairs Down Prefab and Stairs Up Prefab — accept prefabs dragged from the Project window. If you leave the Wall Prefab empty, Rebuild lays down floors but skips visual walls, which is handy when you just want to see the grid.

Below the slots you'll see the Cell Size — the tile size in Unity units. This value is read automatically from the GridCoreBridge component in your scene, which is the only place it is set, to avoid conflicts. If GridCoreBridge isn't present the generator warns you with a yellow message.


Step 1 — Generate Flags

The Step 1: Generate panel has a green Generate Flags button. Clicking it creates a tile grid in the scene almost instantly. It does not build walls or floors yet — it creates only flag objects (small GameObjects with a GridFlagExtended component) under [Generated] DungeonRoot → Flags.

Each flag is one tile with a type (Floor, Stairs, Secret, TrapDoor) and four booleans — north, south, east, west — that mark whether each side is open (a passage) or closed (a wall). After generating you can select any flag in the scene and change its type or walls directly in the Inspector, giving you full control over every tile before anything is built.


Spawn Tools

The Spawn Tools panel adds elements to the grid manually:

  • Floor Tile — a single floor tile, placed at the origin for you to move into position.
  • Stairs Up / Stairs Down — a stair tile with a StairsMarker component that remembers the direction. Rebuild places the correct stair prefab at the correct rotation, calculated automatically from the tile's open walls.
  • Party Spawn — the party's starting point, one per scene. If one already exists the generator selects it instead of creating a duplicate. The JSON export reads its position and facing so the party starts in the right place.
  • Secret Cell (purple button) — a tile of type Secret, shown with a purple gizmo. After export it becomes a regular Floor tile with isSecret = true: the party can walk onto it, but the map never reveals it until they step on it.
  • Trap Door (orange button) — a tile of type TrapDoor that exports to a Floor tile with isTrapDoor = true. It looks like normal floor but acts like a hole at runtime. For it to function you also need to place a TrapDoorTrap prefab on the same grid position — Spawn Tools won't do that automatically.

Step 2 — Build

The Step 2: Build panel has two helper toggles and the main Rebuild button. Hide / Show Flags hides the flag GameObjects so you can see just the geometry, and Hide / Show Meshes disables MeshRenderers so you can see just the flags while laying things out.

Rebuild Dungeon (blue) is the actual build step. It reads every flag in the scene — both generated and manually added — and instantiates wall, floor and stair prefabs from them. Walls land exactly on the tile edge, rotated to face the correct direction. You can click Rebuild as many times as you like; each pass removes the old geometry and rebuilds from the current flags. Doors, traps and chests you placed by hand are not touched — only Walls, Floors and Stairs.


Content Libraries — Doors, Traps, Secret Walls, Chests

Four panels manage your reusable content, all working the same way.

The Doors & Blockers panel uses a Door Library ScriptableObject. You create it via Create → Dungeon Crawler Framework → Door Library or the button in the panel. The library is a list of entries, each with a Name (for example "Iron Gate"), a Prefab and a Description. A green + ADD to scene button next to each entry places the prefab under [Generated] DungeonRoot → Doors, where you move it into position beside a wall.

The Trap Library panel works identically for traps, placing them under [Generated] DungeonRoot → Traps. Each trap needs a TrapMarker component for the JSON export to register it and pass it to the runtime trigger system.

The Secret Wall Library panel manages secret walls, placed under [Generated] DungeonRoot → SecretWalls, and the Chest Library panel manages chests, placed under [Generated] DungeonRoot → Chests.


Step 3 — Export

The Step 3: Export panel finalises the level. It offers three buttons that assign the unique identifiers the trigger system relies on:

  • Generate Unique IDs (all doors) — gives every door a unique blockerId, targetId and sourceId. Without these the trigger system can't tell which door matches which button or event. Always run this before exporting.
  • Generate Unique IDs (all traps) — assigns a unique trapId to each TrapMarker; projectile traps also receive a targetId.
  • Generate Unique IDs (all walls) — assigns targetId to WallCore components, needed when something in the game must interact with a specific wall.

Finally, Build Grid (Export JSON) does the heavy lifting. It reads all grid flags (position, type, walls, stair direction, secret and trap-door flags), all doors and blockers with their IDs and orientations, all traps, the party spawn point with its facing, and any entities carrying GridEntityMarker components. From all of this it writes a single GridData_SceneName.json file into the Resources folder. The runtime loads this file via Resources.Load when the level starts — that single JSON file is the only connection between the editor and the game.


Clear Dungeon

The Clear Dungeon panel (red button) removes everything the generator created — flags, walls, floors and stairs. Doors and other content you placed manually stay put, because the generator knows that was your work. After clearing the geometry it asks whether you also want to delete the JSON file for the scene; if you confirm, the runtime will no longer be able to load that level.


Workflow Summary

  1. Pick a preset or configure the parameters manually.
  2. Click Generate Flags to create the grid.
  3. Edit flags in the Inspector or add new ones with Spawn Tools.
  4. Optionally save the layout with Layout Snapshot → Save.
  5. Click Rebuild Dungeon to build the 3D geometry.
  6. Place doors, traps, secret walls and chests from the libraries.
  7. Click Generate Unique IDs for doors, traps and walls.
  8. Click Build Grid (Export JSON) to write everything to the JSON file.
  9. The runtime loads that file and your dungeon comes to life in game.

One tool takes you from an empty scene to a finished level, step by step, without writing a single line of code.


Dungeon Crawler Framework — Mantis3de