Dungeon Architect for Unity 1.20 Help

Runtime Dungeons

Setup Runtime Build Script

Dungeon Architect can build dungeons at runtime, so you can have a new dungeon everytime you play

You do this by calling the Build() function on the Dungeon component

Create a new C# script anywhere in the project window

Ut 13 28
Ut 13 29

Open the script for editing

using DungeonArchitect; using UnityEngine; public class MyDungeonBuilder : MonoBehaviour { public Dungeon dungeon; void Start() { if (dungeon != null) { dungeon.Build(); } } }

Here, we've provided a public attribute named dungeon of type Dungeon. You'll need to import the DungeonArchitect namespace using DungeonArchitect;

Create a new GameObject and rename it to something appropriate

Ut 13 30
Ut 13 31

Reset the transform

Ut 13 32
Ut 13 33

Add our script to this game object

Ut 13 34
Ut 13 35

Notice the Dungeon parameter is exposed. This is because we made a public attributed named dungeon in our code

public Dungeon dungeon;

Assign your dungeon reference here.

Ut 13 36

When you hit play, this dungeon will be built (since we call dungeon.Build() in the Start method)

Ut 13 38
Ut 13 37

Randomize Dungeon

You might want to have a different dungeon everytime you play

You do this by setting the seed parameter in the dungeon configuration before calling Build()

dungeon.Config.Seed = (uint)(Random.value * int.MaxValue);
using DungeonArchitect; using UnityEngine; public class MyDungeonBuilder : MonoBehaviour { public Dungeon dungeon; void Start() { if (dungeon != null) { dungeon.Config.Seed = (uint)(Random.value * int.MaxValue); dungeon.Build(); } } }
Last modified: 24 January 2024