4. Dialogue class reference
4.1 Bridge, view and player
| Member | Description |
|---|---|
Dialogue.Bridge | the active DialogueBridge (auto-resolved) |
Dialogue.SetBridge(DialogueBridge) | sets the bridge explicitly |
Dialogue.Player | the DialogueGraphPlayer |
Dialogue.View / SetView(IDialogueView) | the presentation view |
Dialogue.IsFunctionRunning | a function is awaiting a result |
Syntax
Dialogue.SetBridge(DialogueBridge)
Parameters
| Parameter | Description |
|---|---|
instance of DialogueBridge | the bridge to set as active |
Notes
Dialogue.Bridge resolves the active bridge automatically. Dialogue.View and SetView(IDialogueView) expose and set the presentation view. Dialogue.IsFunctionRunning indicates the presence of a function awaiting a result.
4.2 Panel and text
| Member | Description |
|---|---|
ShowPanel() / HidePanel() | shows/hides the dialogue panel |
IsPanelVisible | panel state |
ShowText(speaker, text) / ShowText(text) | writes a line |
SetSpeaker(string) / SetText(string) | updates only one part |
HideText() / HideChoices() | hides text or choices |
Syntax
ShowPanel()
HidePanel()
ShowText(speaker, text)
ShowText(text)
SetSpeaker(string)
SetText(string)
HideText()
HideChoices()
Notes
IsPanelVisible indicates the panel state. The forms ShowText(speaker, text) and ShowText(text) write a complete or partial line; SetSpeaker(string) and SetText(string) update a single part; HideText() and HideChoices() hide text and choices respectively.
4.3 Functions
| Member | Description |
|---|---|
Complete(bool result) / Complete() | closes the function with true/false |
CompleteNeutral() | closes the function without a result (conditions are ignored) |
WaitForCompletion(DialogueActionContext) | Task that completes when the function closes |
RunAction(actionId, parameters = null) | executes an action outside the graph |
HasAction(id) / Actions | registered actions |
Syntax
Complete(bool result)
Complete()
CompleteNeutral()
WaitForCompletion(DialogueActionContext)
RunAction(actionId, parameters = null)
HasAction(id)
Actions
Parameters
| Parameter | Description |
|---|---|
result | boolean outcome with which the function is closed |
DialogueActionContext | context of the function whose closure is awaited |
actionId | identifier of the action to execute |
parameters | parameter dictionary; the default value is null |
id | identifier of the registered action |
Return value
WaitForCompletion(DialogueActionContext) returns a Task that completes when the function closes. HasAction(id) verifies the presence of the registered action; Actions exposes the registered actions.
Example
[DialogueAction("AskPassword")]
public sealed class AskPasswordAction : IAction
{
public void Execute(DialogueActionContext ctx)
{
UIManager.OpenPasswordPanel(success =>
{
ctx.SetResult(success);
ctx.Complete();
});
}
public Task ExecuteAsync(DialogueActionContext ctx, CancellationToken ct) => Task.CompletedTask;
public void Cancel() => UIManager.ClosePasswordPanel();
}
4.4 Audio
| Member | Description |
|---|---|
PlayAudio(track, loop = false) / StopAudio() | ambience track |
PlayVoice(speakerCid, did) / StopVoice() | voice of a line |
StopAllAudio() | stops everything |
RegisterAudioClip(track, clip) | registers a clip at runtime (e.g. from Addressables) |
IsAudioPlaying / CurrentAudioTrack | state |
VoiceEnabled | enables/disables voices |
Syntax
PlayAudio(track, loop = false)
StopAudio()
PlayVoice(speakerCid, did)
StopVoice()
StopAllAudio()
RegisterAudioClip(track, clip)
IsAudioPlaying
CurrentAudioTrack
VoiceEnabled
Parameters
| Parameter | Description |
|---|---|
track | identifier of the ambience track |
loop | indicates the repetition of the track; the default value is false |
speakerCid | identifier of the speaker for the voice |
did | identifier of the line |
clip | audio clip registered at runtime |
Notes
RegisterAudioClip(track, clip) registers a clip at runtime, for example originating from Addressables. IsAudioPlaying and CurrentAudioTrack indicate the playback state; VoiceEnabled enables or disables the voices.
5. DialogueBridge class reference
5.1 Events
| Event | Payload |
|---|---|
OnLine | (string speaker, string text) |
OnChoices | List<ChoiceOption> |
OnDialogueEnd | — |
OnWaitingForActionChanged | bool waiting |
OnGraphJumped | (string graph, string node) |
OnVariableChanged | (string name, DialogueValue value) |
OnQuestChanged | (string questId, QuestState state) |
OnPositionChanged | DialoguePosition |
ChoiceOption exposes Text, Did, Next, Index, Condition, Enabled/Visible (according to the option condition).
5.2 Dialogue control
| Member | Description |
|---|---|
Initialize() | initializes (synchronous: desktop) |
InitializeAsync() | initializes (asynchronous: mandatory on mobile) |
IsInitialized | state |
StartDialogue() | starts from the start node; if the init is in progress the start is deferred |
Continue() | advances to the next line |
Choose(int index) | selects an option |
StopDialogue() | stops and cancels the actions in progress |
Restart() | restarts from the beginning |
Reload() | reloads the project (asynchronous on mobile) |
IsDialogueActive, IsWaitingForAction, PendingActionId | state |
SetGraphPath(string) | changes graph before the start |
Project, Graph, GraphPath, Manifest | loaded data |
Validate() | DialogueProjectValidator.Report |
Syntax
Initialize()
InitializeAsync()
StartDialogue()
Continue()
Choose(int index)
StopDialogue()
Restart()
Reload()
SetGraphPath(string)
Validate()
Parameters
| Parameter | Description |
|---|---|
index | index of the option to select in Choose(int index) |
| path | path of the graph set by SetGraphPath(string) |
Return value
Validate() returns a DialogueProjectValidator.Report.
Notes
Initialize()is synchronous and is intended for desktop;InitializeAsync()is asynchronous and is mandatory on mobile.
StartDialogue()starts from the start node; if initialization is in progress the start is deferred.
StopDialogue()stops the dialogue and cancels the actions in progress.
Reload()reloads the project and is asynchronous on mobile.
IsInitialized,IsDialogueActive,IsWaitingForActionandPendingActionIdindicate the bridge state.
Project,Graph,GraphPathandManifestexpose the loaded data.
The example of initialization and manual start of the bridge is reported in section 12.2.
5.3 Language
| Member | Description |
|---|---|
CurrentLanguage / CurrentLanguageLabel | current language (code and label) |
AvailableLanguages | distributed list |
SetLanguage(lang, restartIfActive = true) | changes language |
CycleLanguage(restartIfActive = true) | advances to the next one |
RefreshLanguages() | re-reads the languages from the manifest |
Syntax
SetLanguage(lang, restartIfActive = true)
CycleLanguage(restartIfActive = true)
RefreshLanguages()
Parameters
| Parameter | Description |
|---|---|
lang | code of the language to set |
restartIfActive | indicates the restart of the dialogue if it is active; the default value is true |
Notes
CurrentLanguage and CurrentLanguageLabel expose the code and the label of the current language; AvailableLanguages exposes the distributed list. RefreshLanguages() re-reads the languages from the manifest.
5.4 Savable state
string vars = bridge.SaveVariableState(); // variables only
bridge.LoadVariableState(vars);
string state = bridge.SaveNarrativeState(); // variables + quests
SaveVariableState() serializes the variables only; LoadVariableState(vars) restores them. SaveNarrativeState() serializes variables and quests.