Creating a Skald Conversation Handler in Unity
Build a custom dialogue presenter for Skald conversations
Creating a Conversation Handler in Unity
The included Skald prefab is enough for prototyping, but most games need dialogue that matches their own UI. The plugin separates conversation logic from presentation so you can plug in your own renderer.
The bundled Presentation script in Assets/Skald/Demo/Code/Presentation.cs is a complete UI Toolkit implementation you can use as a starting point.
To create your own conversation handler, you need to implement your own or modify the Presentation.cs script.
How to handle conversations
The runtime stack has two main pieces:
DialogueEngine— loads a synced project, tracks variables, and walks the conversation graphIDialoguePresenter— your code that displays dialogue and collects player input
The engine calls your presenter when it needs to show dialogue, show choices, or end a conversation. Your presenter calls back into the engine when the player continues or selects a choice.
Implement IDialoguePresenter
Create a class that implements the presenter interface. The interface is:
public interface IDialoguePresenter
{
void ShowDialogue(SkaldCharacter character, string dialogue);
void ShowOptions(Option[] options);
void EndConversation();
}ShowDialogue— display a line of dialogue.ShowOptions— display player choices. EachOptionhas display text and anIsAvailableflag based on preconditions.EndConversation— called when the graph reaches an end node.
Load a project and start a conversation
After syncing a project, create a DialogueEngine and load the JSON file:
var engine = new DialogueEngine(myPresenter);
engine.LoadProject("Assets/Resources/Skald/your-project-id.json");
var conversation = engine.StartConversation("Example Conversation: The Forest");LoadProject deserializes the engine export and initialises variables from their default values.
StartConversation finds the conversation by title and begins at its default start node.
Handle player input
The engine returns a DialogueEngine.Conversation object that holds the current state. Wire your UI callbacks to it:
// When the player clicks Continue on a dialogue node
conversation.Continue();
// When the player picks a choice (by index)
conversation.SelectOption(choiceIndex);What the engine handles for you
You do not need to interpret graph structure yourself. The engine:
- Evaluates assignment and conditional nodes
- Checks player choice preconditions
- Interprets rich text and expressions using project variables
- Resolves the next node based on player selections and branch logic
Variables
Synced projects include variable definitions with default values. The engine exposes them through engine.Variables as a dictionary keyed by variable name.
Call engine.ResetVariables() to restore defaults, for example when restarting a conversation or starting a new playthrough.
Tips
- Keep a reference to the active
Conversationobject so your UI can callContinueorSelectOption. - Remember to re-sync from Skald when you make changes at https://skald-eval.dual-daggers.com, as the engine reads from the local JSON file, not the live API.