Generation
Deterministic weighted WFC with propagation and backtracking, rectangle/ellipse/diamond/cross footprints, connectivity repair, entrances, exits, guaranteed treasure, and reproducible seeds.
Wave-function-collapse dungeon generation for Unity 6 URP, with runtime building, live painting, six themes, stacked floors, gameplay hooks, NavMesh agents, editor tools, and a complete interactive demo.
Version 1.6.1 Unity 6 URP 17 Full C# sourceDungeon Generator creates connected, playable, isometric-style stone dungeons from a deterministic seed. Its pure-C# WFC core solves tile adjacency and carving, while the Unity runtime builds modular floors, walls, doors, canals, cave rims, graveyards, props, lighting, gameplay elements, and navigation.
The generated result remains editable. Paint terrain families, stamp exact tiles, restyle individual walls, swap themes and models, tune weights, undo changes, serialize a complete dungeon code, or query the solved plan from your own systems.
Assets/DungeonKit/Demo/Scenes/DungeonKitDemo.unity to explore the complete feature set.Starting from a non-URP project? Use Tools > Dungeon Kit > Setup URP. The tool lists the project settings it proposes to change and waits for confirmation.
GameObject > Dungeon Kit > Dungeon Generator.StoneKitLibrary is located and assigned automatically.The art kit is already baked under Assets/DungeonKit/Art. Tools > Dungeon Kit > Build Demo Assets is an authoring command that rebuilds and overwrites those generated art assets; use it only when intentionally changing the art-generation code.
Deterministic weighted WFC with propagation and backtracking, rectangle/ellipse/diamond/cross footprints, connectivity repair, entrances, exits, guaranteed treasure, and reproducible seeds.
Cave, graveyard, void, and canal carving; cell painting and erasing; local perturbation; exact wall/door/corner/canal stamps; local re-solving; and undo.
One to three independently solved floors joined by stairwells, optional terraces and basements, critical-path key/lock progression, room purposes, and furnished spaces.
Stone, Crypt, Moss, Blocks, Rough, and Sewer themes; wall variants; modular prefab replacement; density-controlled props; atmosphere, torch, light, and audio controls.
Interactive chests, spike traps, collectible keys, opening gates, event callbacks, click-to-move player, runtime navigation, zombie agents, and deterministic spawn rules for your prefabs.
Dungeon Designer window, minimap, validation and region overlays, 2D raster export, PNG export in the demo, dungeon codes, URL seed/code loading in WebGL, and OBJ model swaps.
The demo intentionally exposes the generator’s major systems in one place. A useful evaluation path is:
?seed= / ?code= to a hosted WebGL demo URL.using DungeonKit;
using DungeonKit.Core;
var gen = GetComponent<DungeonGenerator>();
gen.settings.width = 16;
gen.settings.height = 12;
gen.settings.seed = 12345;
gen.settings.caveBites = true;
gen.settings.forceCanal = true;
gen.Generate();
gen.PaintCell(4, 5, PaintKind.Cave, autoSolve: true);
gen.PerturbCell(7, 3);
gen.EraseCell(4, 5, autoSolve: true);
gen.Undo();
bool walkable = gen.IsWalkable(x, y);
bool passable = gen.IsPassable(x, y, dir); // 0=N, 1=E, 2=S, 3=W
Vector3 world = gen.CellToWorld(x, y);
DungeonPlan plan = gen.Plan;
DungeonQuery query = gen.Query;
int depth = query.DepthFromEntrance(cell);
float normalized = query.NormalizedDepth(cell);
bool onCriticalPath = query.IsOnCriticalPath(cell);
string code = gen.SaveCode();
if (!gen.LoadCode(code, out string error))
Debug.LogError(error);
var player = GetComponent<DungeonPlayerSpawner>().Spawn();
player.MoveTo(worldPoint);
GetComponent<DungeonNpcSpawner>().SetPopulation(12);
DungeonEvents.ChestOpened += position => DropLoot(position);
DungeonEvents.TrapTriggered += position => DamagePlayerNear(position);
DungeonEvents.GateUnlocked += lockIndex => Fanfare();
var settings = new GenerationSettings { width = 20, height = 14, seed = 7 };
var model = new DungeonModel(settings);
model.Generate();
DungeonPlan plan = model.Plan;
Open Assets/DungeonKit/Art/StoneKitLibrary.asset. Each module is a prefab slot. Walls and edge strips are authored along the north edge of a 4 × 4 metre tile and rotated by the builder. Replace compatible slots with your own prefabs and use tileSize to rescale the grid.
GenerationSettings.weights exposes wall density, canal amount and curvature, cave/void/grave prevalence, open-space boost, and related weights. Generate() rebuilds the logical tile catalog before solving. If you change weights and immediately perform a local edit without regenerating, call RebuildCatalog() first.
Add rules to DungeonSpawnRules to scatter project prefabs by depth band, terrain family, chance, cap, and wall alignment. Placement is deterministic for a given dungeon seed.
DungeonCulling with a player or other focus transform for large runtime dungeons.| Unity | Built with Unity 6000.0.62f1. Unity 6 (6000.0) or newer is required. |
|---|---|
| Rendering | Universal Render Pipeline required for the bundled materials; the project uses URP 17.0.4. |
| UI | uGUI is used by the demo. The generation runtime remains separate from the demo assembly. |
| Input | The demo supports old, new, or both input-backend settings. The Input System package is optional and is only needed when the project selects the new backend. |
| Platforms | Windows 64-bit and WebGL demo builds have been produced from this project. Other targets have not been claimed as verified. |
| Colour space | The bundled art is authored for Linear colour space. |
The project is not using URP or the package is missing. Install URP and use Tools > Dungeon Kit > Setup URP, or assign your own materials and prefabs in the tile library.
If Active Input Handling is set to Input System (New), install com.unity.inputsystem. The demo creates the matching EventSystem module at runtime.
Generate once after changing weights, or call RebuildCatalog() before a paint, perturb, erase, or stamp operation.
Reduce clutter and torch density, avoid rebuilding every frame, and enable runtime culling. Build once and use the query/event APIs for gameplay whenever possible.
The runtime importer normalizes supported model slots to their expected footprint and pivots geometry to its base. For exact production control, prepare and assign a Unity prefab directly in the tile library.
Use of this package is governed by the license under which it was acquired through the Unity Asset Store. Unity packages referenced as project dependencies remain governed by their respective Unity terms. No separate third-party content notice is included with this asset.
For questions, bug reports, or feature requests, contact szekipapa77@gmail.com. Include your Unity version, target platform, a short reproduction description, and relevant Console output or screenshots.