Skip to content

danialaa/DialogTreeSystem

Repository files navigation

Dialog Tree System

A simple dynamic system to build dialogs in a Unity game using an external JSON file

This system is built with MVC (Models including DialogTree, DialogTreeNode, and DialogOption) design pattern with simple usage for game designers, using JSON to deserialize the dialog text into the tree.
Users can replay the dialog, but only choose the choices made in the first dialog-run.
The dialog system also checks if users can get stuck in your dialog (if your dialog has loops) and warns you about it.

To use the system:

  1. Edit the dialog prefab however you like.

You can edit the dialog background image, text fonts, colors, position/size of elements, and button UI.

  1. Attach the DialogOpener component to your scene script

  1. Attach your updated prefab, the name of the speaking NPC, and the name of the JSON file that contains your dialog. make sure the file is in the Resources folder
  2. Whenever you wish to start the dialog, just call for the DialogOpener.startDialog() function.

Dialog Tree in JSON

An example of the JSON structure required is attached here. Which contain a list of text nodes along with its options (a max of 3).

Future work

-To add the ability to structure the dialog via inspector.
-To increase option numbers (adding left and right buttons to see all options).

About

A simple dynamic system to build dialogs in a Unity game using an external JSON file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published