Dungeon Architect for Unity 1.20 Help

Design your first Theme

A theme file is a mapping between marker names (like Walls, Ground, Door etc) and the meshes that you provide. The prefabs you map here will be used to build your dungeon

Ut 02 theme editor preview

In the previous section, we created a dungeon with an existing theme file (CandyDungeonTheme). In this section, we'll create one ourselves

Create a Theme File

Create a new theme file from either the Main menu or the Create menu

Create from Main menu
Create from Create menu

This will create a theme file in the current open directory in the Projects window

Ut 02 03

Open the Theme File

Double-click the theme file to open the Theme Editor. Dock the theme editor so you can see both the Scene view and the Theme Editor at the same time

Ut 02 04

Assign the Theme File

Destroy the existing dungeon by selecting DungeonGrid game object and click Destroy Dungeon button

Assign the theme file that you just created, on to the DungeonGrid game object

Ut 02 05

Click Build Dungeon and nothing should appear. That's because we haven't added prefab mappings on the theme yet

Design the Theme

Navigate to Assets\DungeonArchitect_Samples\Demo_Theme_Candy\Prefabs. This folder contains a set of mesh prefabs we can use for our dungeon

Ut 02 06

Add Ground

Drag-drop the ground prefab mesh on to the Theme Editor

Ut 02 07

Link up the mesh node with the Ground marker node. When you do, you should see a live preview on the scene view with the dungeon using this ground mesh

Ut 02 08

For the live preview to work, make sure the "Realtime Update" button is enabled in the Theme Editor

Ut 02 09

Another criteria for the live preview to work is that a dungeon in the scene should reference the theme that is currently being edited in the theme editor

Adjust Object Transform

Dungeon Architect can adapt to any modular asset. In our example, the dungeon's grid size is set to (4, 2, 4). The ground prefab that we used has the same size (4x4) and the pivot is in the center. So it will fit nicely without any change

Ut 02 37
Ut 02 38

However, this might not always be the case. Your prefabs might have its pivot in a different position (like in the corner) and the size may be different than the grid size we've defined in the dungeon game object.

Here's an example of a modular ground prefab from one of the Synty asset.

Ut 02 39

The Pivot is in the corner and the size of the tile is 5x5 units

If we were to drop this in the theme editor and link it to the ground marker, we'd see this

Ut 02 40

The tiles overlap since the asset is bigger than the grid size (we chose the grid size to be 4 and the asset size is 5)

Select the mesh node and set the scale to 0.8 (since 4/5 = 0.8)

Ut 02 42
Ut 02 41

Now we need to align the position. Click Visualize Markers from the theme editor's toolbar

Ut 02 43

Select the ground prefab node or the Ground marker node to visualize the correct position of where your meshes should be

Ut 02 44

Use a corner as a reference for alignment, like in the image above

We'll move it along X by -2 and see where it goes

Ut 02 46
Ut 02 45

That doesn't seem right. Move the X along 2 instead and it fits correctly along the x-axis

Ut 02 47
Ut 02 48

Move along Z by 2 units to bring it to the correct position

Ut 02 50
Ut 02 49

Marker Visualizer

As we've seen in the previous section, the theme editor's Marker Visualizer is a useful feature while designing your dungeons. It will show the alignment guides whenever you select a built-in marker node (like Ground, Wall etc) or any node connected underneath it

Turn it on from the Theme Editor's toolbar and select a built-in marker node or any node underneath it to visualize that marker's expected alignment

Ut 02 43
Ut 02 51
Ut 02 52
Ut 02 53
Ut 02 54

Add More Prefabs

Go ahead and add prefabs under the following markers: Wall, Fence and Door

Ut 02 10
Ut 02 11

Add Wall Pillars

Drag drop the Pillar2 prefab to the theme editor and link it to the WallSeparator marker node

Ut 02 12

We'll need to make this pillar a bit bigger. Select the node you just dropped and modify the Scale parameter under Offset category

Ut 02 13
Ut 02 14

Add Windows

We have two wall meshes in the samples folder

Ut 02 15

The other one (Wall2) has a window. Lets configure the theme to sometimes use this second mesh so we have windows

Drag drop Wall2 prefab on to the theme editor and place it before (left of) the existing wall prefab node

Ut 02 16

When you connect this to the Wall marker node, you'll notice it has picked up the window node for all the walls

Ut 02 17

This is because Dungeon Architect starts executing the nodes from left to right. When the condition was satisfied to pick the first node, it stopped execution and never came to the second node.

There are multiple ways you can control this condition, the simplest being adjusting the probablity of selection.

Select the node you just dropped and change the probability to 0.5 (this would mean it gets selected 50% of the time). The other 50% of the time, it would not be selected and the execution would then move to the next node, and hence selecting the non-windowed wall node

Ut 02 18
Half the walls have windows

Add Wall Decorations

There's a photo frame prefab we'd like to attach to every wall

Ut 02 20

Drag drop this prefab to the theme editor before the two existing nodes and link it to the Wall marker node

Ut 02 21

This will cause all the walls to disappear and be replaced with this photo frame

Ut 02 22

This is because once the photo frame was selected, the execution stopped and the the wall nodes further down the line were not executed.

Select the photo frame and uncheck the flag "Consume on Attach". This will cause the execution to continue further even though this node was selected by the theming engine

Ut 02 23

Lets adjust the offset of the photo frame (position and rotation) to make it properly align with the inner walls

Select the photo frame node and change the position to (0, 2, -0.22) and rotation to (0, 180, 0)

Ut 02 24

The photo frame is aligned with the walls

Ut 02 25

Marker Emitters

We have an issue with the photo frames. They also spawn near windows

Ut 02 26

Marker Emitters allow you to emit marker names from any of your dropped prefab nodes. This means, we can define a new marker node (e.g. MyWallDeco) and then emit that marker from the wall node that doesn't have a window (Wall1 prefab). All our wall decorations can now go under this MyWallDeco marker and it will show up only near solid walls

Right click on an empty area in the theme editor and select Add Marker Node

Ut 02 27

Select the node and change its name to MyWallDeco

Ut 02 28

Break the link to the photo frame

Ut 02 29

Connect this under MyWallDeco marker node. All the future wall decorations can also go under this marker

Ut 02 30

Now emit this marker from the wall node that doesn't contain a window

Drag a link out of the bottom of the solid wall prefab node and release the mouse in an empty area

Ut 02 31
Ut 02 32

You can follow the same method to create another type of decoration (e.g. MyWindowDeco) and emit it from under the windowed wall node. In this example, I've added a flower pot in the windows

Ut 02 33

Recap

In this section we learnt the following:

  • Probablity - Controls the percentage chance of a node being selected. A value of 1 means 100% selection chance. A value of 0.25 means 25% selection chance

  • Execution Order - The theme engine executes all the nodes under a marker node from left to right. If it selects a certain node, it stops executing, unless the Consume on Attach flag is unchecked

  • Marker Emitters - You can create complex hierarchies with your own marker nodes, giving you more freedom to decorate your dungeons

Last modified: 24 January 2024