суббота, 4 февраля 2017 г.

Node-based Visual dialogue Editor for Unity


I'm working on visual node-based dialogue editor for Unity. Currently, I have alpha that allows not only to draw dialogue nodes, but call functions, check conditions and wait for events. I've already tested it into my small text quest and found it very usefull and handy. On a screenshot below you can see, how some dialogue may looks inside my editor:


The interface is pretty simple, almost everything is driven through context menues and hotkeys.
What is so interesting you can see here?

Function calls.
You can implement any function in C# and call it in your script. (See third node) It supports various arguments. Currently, only string, float. int, bool and Unity.Object types of args are supported. On a sample you can see, that function "ShowWindow" is called with argument "NameForm". In order to be invoked, function must be exposed on C# side by calling a method. After this, function will be available from any dialog asset.

Event Bindings.
As you can see, after "ShowWindow" node, there is another node. This node suspends dialog evaluation until event OnScreenClosed will be fired. This event declared on c# side as event without any parameters. When event will be triggered, dialog will continue it's flow.

Branching.
It supports branching. You can see that dialog has three options to continue. Node "Switch Dialog Flow" let you to create branches of options. Selection type:"User Selected" means, that every option after Switch node will be displayed on a screen, and after player makes a choice, dialog continues.
  
Conditions.
You can create and check conditions inside dialogues. Every dialogue node has a field where you can write some expression to check. Expression is formed from conditions. Condition has its name and state: true, false, notexisted. On example below, there is only one condition: door_closed. It is created for a first time with its state set to false. If player ask NPC to close a door, then condition will change it's state to true and dialog flow will be returned at switch where node "Close the door" won't be shown for that time.

RoadMap:
I'm going to implemet some extra features, after that editor will be available at Unity Store:
  • Exposing variables
  • Support for math and boolean expressions
  • In-script varialbes and functions definitions
  • Binary serialization of data, stored inside of nodes
  • Support for localization