Node Editor


Since we are making a point-and-click adventure game, a lot of dialogue has to be written. Which means a lot of decision and question trees. Which is not fun to hard-code. So I made a node editor for our writer to use. Which makes it way more sane and visible how the dialogue will flow.

The editor was built from an open source node editor that I stumbled upon somewhere in the Unity forums. It was made by unimechanic and can be found here. Although some major restructuring was needed for my purposes.

For you who just want to see the current result, here is an image:

Node editor

What I want

Basically I wanted to make it easier for the writer to get an idea how the conversation would flow. Since a conversation in its basic sense is composed of questions and answers, it is easy to construct every kind of conversation by these two simple blocks (in this case a reply is always offered by an NPC, even questions and questions by the player).

To give the writer more control over what happens with the dialogue, tokens can be used to change the text speed (20), trigger an animation [scratch_head] and play sound effects [yawn]. A script analyses the text and looks for these tokens by regular expressions which then feed into a system that triggers those events. An example of this could be:

In-text identifiers for speed and emitting sounds.

Another thing that is needed is conditional logic for the display of the conversations. A way to see what kind of dialogue options are presented based on an inventory and a knowledge base (an inventory for things the player knows). These are yet to be implemented, but when I finish that, I’ll do a follow-up post. Right now I am struggling with how I am going to implement that into something visualization.

What I changed

The previous node editor was made for calculation purposes and that put some restrictions on the design of the nodes. For example, any node could only have one input. This makes sense from a calculation perspective, because, what are you going to do with the two values? Add, subtract, divide or power? However, this is needed for dialogue trees. You want to be able to, for example, have multiple replies leading to one question.

Here I pretty much deleted everything that was to do with calculations since it worked against what I wanted and changed the base class for the nodes in such a way that it would take multiple in- and outputs.

Node scriptable object

That doesn’t sound too hard, but most of the logic depends on the fact that only one input is a given, thus needing to restructure much of the framework. I almost thought of making my own node editor from scratch. Then I remembered how much I like to write GUI related code. Nope, I was not doing that.


The framework initially provided by unimechanic and improved by Seneral. It is currently still in development and they have a trello board where you can suggest ideas which has since been removed :(. The source code for the version I used can be found on GitHub and is already way better than what I used a few days ago.

It isn’t perfect for what I want, but it works well enough and I might one day make a branch of the project on GitHub and provide a free and robust system for more people to use. There are some great payed plugins on the asset store but making something like this yourself will learn you a lot about ScriptableObject use, Unity Editor Scripts and mostly YOURSELF. Plus I like doing these things to improve my coding.