5. Engine execution cycle
| Class | Role |
|---|---|
DialoguePaths | all positions of the contract; no other file may construct paths |
DialogueStreamingAssets | per-platform I/O (direct file or UnityWebRequest) |
DialogueProjectLoader | prepares the project and loads the graph |
DialogueProjectManifestLoader | reads engine.manifest.json |
LanguageManager | current language, available languages, saved preference |
YamlLineProvider | in-memory line database (GetLine(cid, did)) |
CharacterRegistry | CID → displayed name |
DialogueVariableCatalog | variable declarations |
DialogueGraphIndex | graph index + in-memory graphs (used by jump nodes) |
GraphYamlParser | YAML ↔ GraphData |
DialogueGraphPlayer | executes the graph: nodes, choices, waits, functions, audio |
ActionRegistry | discovery and instantiation of the actions |
DialogueBridge (MonoBehaviour) | facade: events, language, variables, quests, position |
Dialogue (static) | convenient API for the game |
DialogueUICanvas / DialogueOverlayUI | presentation (IDialogueView) |
DialogueProjectValidator | graph/line consistency checks |
The startup sequence, valid on both desktop and mobile, is the following:
GameSetup/DialogueBridge.Awakestarts initialisation (asynchronous on mobile, synchronous on
desktop).
DialogueProjectLoaderreads manifest → languages → characters → variables → graph index → graph.
YamlLineProviderloads the lines of the selected language.
- The bridge connects the variables (with
QuestVariableMirror) and creates the player.
StartDialogue()starts from thestartNodenode;Update()callsTick()every frame.
The call to StartDialogue() performed before initialisation has finished is not lost: it is deferred (_startWhenReady).
5.1 DialogueGraphPlayer — states
| State | Meaning |
|---|---|
Running | is showing a node or advancing |
WaitingForChoice | waits for Choose(index) |
WaitingForAction | waits for the end of a function (with safety timeout) |
| stopped | dialogue terminated (End or finished graph) |
The following rules apply:
Tick()advances the typewriter and the waits; it is not necessary on desktop only because the
events arrive from the bridge, but it is mandatory if the game drives the player on its own.
- On desktop the action is executed on the Unity main thread; the internal waits use
ConfigureAwait(false) so as not to block Tick().
StopDialogue, language change, graph change and bridge destruction callCancel()on the actions
in progress.
6. Management of functions and actions
The interface contract is the following:
public interface IAction
{
void Execute(DialogueActionContext context);
Task ExecuteAsync(DialogueActionContext context, CancellationToken cancellationToken);
void Cancel();
}
With regard to automatic discovery: a class decorated with [DialogueAction("NomeAzione")] is found at startup and its name appears in the dropdown of the Function node. MonoBehaviours are rejected with a warning: the actions must be pure classes, since they are instantiated by the engine.
The DialogueActionContext object exposes: ActionId, Node, Graph, Speaker, Language, Parameters (with GetParameter, GetInt, GetFloat, GetBool), Player, Variables, Quests, Completion, Result, plus the commands SetResult(bool), SetNeutral(), Complete().
| Concept | Behaviour |
|---|---|
Wait for completion on the node | the dialogue stops until the function closes |
ctx.SetResult(true/false) | routes the dialogue onto the True/False outputs of the connected Condition nodes |
ctx.CompleteNeutral() | neutral result: the normal output is taken, the conditions are ignored (with a warning if any exist) |
CompletesExternally = true | the function remains open until the game calls Dialogue.Complete(...) |
FunctionTimeoutSeconds | if nobody closes within the time, the engine closes by itself and proceeds |
| Exception in the action | log [305], the function closes in neutral mode, the dialogue continues |
On Parallel (Dialogue node) | action started in parallel while the line is on screen |
On Complete (Dialogue node) | action executed when the line has been read |
The built-in actions are the following:
| Id | Parameters | What it does |
|---|---|---|
LogDebug | message | writes to the Console |
Wait | seconds | waits N seconds (WaitsForCompletion) |
QuestAccept | questId | accepts a quest |
QuestComplete | questId | completes a quest |
QuestFail | questId | fails a quest |
QuestStep | questId, stepId, done | marks an objective |
ReportResult | result | closes the function with true/false |
ExternalResult | — | closes nothing: waits for the game |