Click on the image below to watch a demonstration video:
Dialogue and Action System for Unity
(or simply DAS_Unity
) is an asset for Unity3D Game Engine which provides an easy way for beginners to create complete dialogues in their games with the most frequent features seen on RPGs such as dialogue ramifications, multiple options, associated actions and so on.
Download this project and copy the contents of "Assets" folder.
Inside your project, create a folder and name it "DAS_Unity" (or whatever you want). Now simply paste the contents inside this folder.
DAS is composed of six classes:
DAS_DialogueController
(attached to an empty object on the scene)DAS_DialogueSystem
(attached to the npc, it has an array of type DAS_Dialogue)DAS_Dialogue
(child of dialogue system, it has an array of strings and/or an array of DAS_Options)DAS_Option
(child of dialogue, it has a DAS_Dialogue target or a DAS_Action)DAS_Action
(abstract class which any script can inherit from, so it can be used as an action of an option)DAS_DialogueBox
(prefab child of canvas)
The image below shows the basic structure described above
Let's take a closer look at the DialogueSystem object, which is a child of the Character(NPC). It contains a DAS_DialogueSystem script attached to it, as you can see below
The DAS_DialogueSystem is composed of the following variables:
Dialogue Controller
: The DialogueController of the scene (only one per scene)Dialogue Box
: The DialogueBox (child of canvas) that will be used by this characterDialogues
: Array of DialoguesPhrase Speed
: The speed of the typing animation of the dialoguePhoto
(Optional): If you set a sprite here, all the child dialogues can inherit this sprite (it's the character profile image)Title
(Optional): If you set a title here, all the child dialogues can inherit this title (title of the dialogue box, usualy the character's name)Random
: If checked, dialogues will be shown at random orderAction When Start
(Optional): Here you can set a script that inherits DAS_Action to be executed when the dialogue startsAction When Finish
(Optional): Here you can set a script that inherits DAS_Action to be executed when the dialogue ends
Ok, now let's see about the Dialogue objects, which is a child of the DialogueSystem object and contains a DAS_Dialogue script attached to it, as you can see below
The DAS_DialogueSystem is composed of the following variables:
Last One
: If checked, the dialogue with the character will end when this dialogue is reachedPhrases
: An array of strings that will be the dialogue itself (use only one phrase if this dialogue has options)Options
(Optional): An array of Options that will be displayed inside this dialogueInherit Style
: If checked, this dialogue will use the photo and title of the parent DialogueSystem, if it has those variables assignedPhoto
(Hidden/Optional): If InheritStyle is unchecked, you can attribute a specific photo to this dialogue onlyTitle
(Hidden/Optional): If InheritStyle is unchecked, you can attribute a specific title to this dialogue onlyPlay Specific Sound
: If checked, when this dialogue is reached a special sound can be playedAudio Source
(Hidden): If PlaySpecificSound is checked, an Audio Source must be providedSpecific Sound
(Hidden): If PlaySpecificSound is checked, an Audio Clip must be providedAnimate Phrases
: If checked, an animation will simulate the typing of the stringsPlay Typing Sound
(Hidden): If AnimatePhrases is checked, here you can choose if animation will have soundJump to Dialogue
: You can check this if you want to redirect to a specific dialogue, instead of the next in the arrayTarget Dialogue
(Hidden): If Jump to Dialogue is checked, a Dialogue must be provided
Example with options:
Since in the last image we saw some DAS_Options variables, let's see how an Option object implements a DAS_Option script:
A DAS_Option has the variables:
Title
: The text of the option itselfEnd Dialogue
: If checked, the dialogue with the character will close when the option is clickedOpen Dialogue
: If checked, a specific dialogue will be called when the option is clickedDialogue
(Hidden): If Open Dialogue is checked, a Dialogue must be providedExecute Action
: If checked, a specific action will be executed when the option is clickedAction
(Hidden): If Execute Action is checked, a script that inherits from DAS_Action must be provided
An example of an Option that closes the dialogue:
If you want to use the Prefab DialogueBox without having to make changes, set your Canvas UI Scale Mode to "Scale With Screen Size" and set the Reference Resolution to 1920 x 1280
And don't forget to add the DialogueBox Prefab as a child of the Canvas!