Skip to content

Getting Started: Scene Setup & First Generation

Now that we have our dungeon flow set up, it's time to generate it.


Setting Up the Generator

Start with a clean scene or an empty GameObject in your existing one.

  1. Create a new GameObject and name it Dungeon Generator
  2. Add the Runtime Dungeon component:
    Add Component > DunGen > Runtime Dungeon

Runtime Dungeon Settings

In the Inspector:

  • Assign your Dungeon Flow asset to the appropriate field
  • Make sure Generate On Start is checked

Now when you enter Play Mode, DunGen will automatically generate a dungeon based on your setup.

🎥 Tip:
Switch to the Scene view during Play Mode to fly around and inspect the layout.

Generated Dungeon Layout

Generating in Code

We can generate a new dungeon in code as follows. Add this new component to any GameObject in your scene and be sure to assign your Runtime Dungeon to the field. Now, pressing R will generate a new random dungeon.

GenerateDungeonOnKeyPress.cs
using DunGen;
using UnityEngine;

public class GenerateDungeonOnKeyPress : MonoBehaviour
{
    public RuntimeDungeon RuntimeDungeon;

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.R))
        {
            var generator = RuntimeDungeon.Generator;
            generator.Generate();
        }
    }
}