This project is a modified version of DoublSB's D'Dialogue System (Original GitHub Repository), a simple dialogue system that uses C# Code to play out dialogues. These modifications help to make the system more usable for broader use, including 3D games and re-triggerable dialogues.
The original system was specialized for single-shot visual novels and 2D-based dialogue, which felt restrictive for me in using it for other uses (even in a visual novel context). I used an older version of this modified system on an old game project, but it has since been scrapped. I am putting in my changes here in this repo for anyone to see or use for thier own purposes under MIT license. I have tested the code on Unity 6 (6000.0.30f) and in the URP pipeline, but it should be able to work on older unity versions or other pipelines just fine (other than maybe some modifications if required).
Do note that I haven't draft out the documentation yet, I will draft out one in the future. You can still refer to the old documentation (it is in the repo as well), as most of its commands and original functionalities are still there.
- Dialogues are now re-triggerable, allowing developers to decide when and how dialogues can be replayed
- Removed Character and Emotion functionality, focusing on text, actor names, and dialogue choices
- Added character name text integration into the UI and Dialogue Manager
- Upgraded to TextMeshPro for better text rendering (can be changed back to using Text instead of TextMeshPro)
- Simplified SFX audio playing
- Enhanced the DialogueAsset prefab to align with these changes
- Download and import the system (via UnityPackage, zip, clone, fork, etc.)
- Locate the
DialogAsset
in the Prefab folder underDDSystem
and add it to your scene - Create a custom dialogue script for your character game object, or refer to the provided
Dialogue_DEBUG
script - Assign references to the appropriate fields in the inspector
Here’s a simple example of creating a dialogue script:
Public DialogManager dialogManager;
void Start(){
//creates the list needed to play the dialogues out on the screen
var dialogTexts = new List<DialogData>();
//this will add a new dialogue to the list, saying "Hello World" by the character, Bill
dialogTexts.Add(new DialogData("Hello World", "Bill"));
//this will play out the dialogue, and it will pop on the screen. Once it is finished, it will automatically turn off
dialogManager.Show(dialogTexts);
}
All commands start with /(Command Name)/. An example of using a command is
//the command we are using is /sound/, which will play a custom SFX clip at that point in the dialogue
dialogTexts.Add(new DialogData("And here we go, /sound/the haha sound!.", "test"
List of possible commands (You can also refer to the documentation as well, just no /emote/ command):
Screenshots from the original repo about the commands (as I don't have time to write through all this at the moment, will update this later on, so treat the screenshots as temporary for now)
The original system's /sound/ command uses /sound(name)/, but here, we can simply call /sound/ and have it replace the SFXaudio audiosource in the DialogAsset prefab
with the correct audio clip by utilizing callbacks. To better demonstrate what I mean, here is an example to explain it
//assume we give this public varaible the haha sfx
public Audioclip HahaAudio;
//We will be using a helper method as a callback. So after we finish the dialogue and want to play the next it, since we set our callback to DialogueExtra, we would first execute the DialogueExtra function
//before playing the next dialogue. Lets say in the DialogueExtra method, we take haha sfx that we have and insert it into the SFXaudio Audiosource's audio clip field in the DialogAsset prefab in our scene.
//So we insert the audio clip to the correct audio source in DialogAsset, so when we play the next dialogue, it will refer to that audiosource in that prefab and play it in that moment in the dialogue
dialogTexts.Add(new DialogData("Blah Blah", "Jill", () => DialogueExtra(HahaAudio)));
dialogTexts.Add(new DialogData("/sound/haha!", "Bill"));
for more information, you can refer to the old documentation or the info in the original repo (Original GitHub Repository).
- Optimize the code
- Better Dialogue Actor/Character to Dialogue Manager system
- Multiple SFX capability for the /sound/ command
- More in-text dialogue commands
- Draft documentation
- Unity DOTS intergration
The base code of the dialogue system is from DoublSB's D'Dialogue System (Original GitHub Repository)