A simple dialogue tree editor for unity
clone the project into your
git clone https://github.com/code51/dialoguesmith
dialogue tree editor
Edit your dialogue tree through editor. access through Window/Dialoguesmith menu.
- A dialogue can have more than one text reserves which can be used for
- a complete runthrough. a convenience without needing to create many dialogues for a single actor.
- a single randomly picked text
- a tree can have many dialogue actor
- it’s not necessarily a name of the actor. it can be an id as a reference to your game actor.
- automatically list the variables found inside the texts/option texts under format
implementation through factory and builder
- a factory/builder to help with the creation of the dialogue runtime. sample can be found in
tons of listeners
- listeners to listen on number of dialogue events
- a factory only have a basic listeners for tree begin, finished, dialogue ready etc. this is used to help with UI building.
- while a builder can have more dialogue specific listeners. this can be used for more sophisticated dialogue building.
There’re multiple ways to implement the use of your dialogues in the scene. while the major feature of this package is mostly about editing a dialogue tree, other being a convenience to use them in the code. Example can be found at
A factory derived from AbstractRuntimeBuilder to help creating a runtime, including setting up the listeners to number of events
without entity loader
using System; using DialogueSmith.Runtime; ... RuntimeFactory factory = new RuntimeFactory(new Random());
with entity loader
An entity loader helps you locate your dialogue tree by it’s string name, instead of TextAsset. The dialogues directory have to be placed inside your resources folder.
RuntimeFactory factory = new RuntimeFactory(new EntityLoader("dialogues"), new Random());
called when the runtime has begun. can be used for UI enabling etc.
called when the runtime/dialogue tree has finished.
called when a dialogue is initializing. can be used to apply dialogue specific variables, filters and so on.
called when a dialogue has been initialized. Can be used to draw the UI update.
called when a dialogue without selections is continuing. and just before the initialization the next dialogue. for selection based continue event, use
called when an option has been selected.
When dialogue is paused. Can be used for UI preparation.
When dialogue is unpaused
factory.OnDialogueTreeBegin(HandleDialogueTreeBegin) .OnDialogueTreeFinished(HandleDialogueTreeFinished) .OnDialogueInitialized(HandleDialogueUpdate) .OnOptionSelected(HandleDialogueSelectionUpdate);
An object that is being used to maintain the state of the dialogue tree in game. originally created by a
RuntimeFactory as explained above.
used to proceed the dialogue. there’re two overrides available for this method. one without argument, second with the argument that requires OptionSelection object. The dialogue tree ends, when there’s no longer dialogue available next.
Pause the runtime. Can be used to do other things while in the middle of a dialogue.
Unpause and continue the runtime
create the runtime, with the first dialogue initialization.
DialogueRuntime runtime = factory.Create(dialogueTreeText);
DialogueRuntime runtime = factory.Create(dialogueName);
A similar class derived from AbstractRuntimeBuilder to handle more sophisticated cases, introducing more than one overrides for existing methods.
RuntimeBuilder builder = factory.CreateBuilder("npc/generic-merchant");
DialogueRuntime runtime = builder.Build();