Skip to main content

API Reference

Complete API reference for DialogueCraft runtime classes, organized by category. All classes are in the DialogueCraft namespace unless noted otherwise.


Core

DialogueRunner

namespace DialogueCraft
[AddComponentMenu("CraftWorks/DialogueCraft/Dialogue Runner")]
public class DialogueRunner : MonoBehaviour

The primary runtime component that plays dialogue assets. Attach to a GameObject and assign a DialogueAsset to begin. Handles node processing, typewriter effects, variable evaluation, sub-dialogues, and voice playback.

Serialized Fields

FieldTypeDefaultDescription
dialogueDialogueAssetnullThe dialogue asset to play.
characterDatabaseCharacterDatabasenullCharacter database for resolving character references. Falls back to DialogueCraftSettings.Characters.
autoStartboolfalseStart dialogue automatically on scene load.
useTypewriterbooltrueEnable typewriter effect for text.
typingSpeedfloat0.05Seconds per character for typewriter effect. Range: 0.01--0.2.
useLocalizationbooltrueUse localized text from LocalizationManager.

Events

EventTypeDescription
OnDialogueStartUnityEventFired when a dialogue begins.
OnDialogueEndUnityEventFired when a dialogue ends.
OnDialogueLineDialogueLineEventFired when a text line is ready to display. Carries DialogueLineEventArgs.
OnChoicesPresentedDialogueChoicesEventFired when choices are presented. Carries DialogueChoicesEventArgs.
OnDialogueEventDialogueTriggerEventFired by Event nodes. Parameters: (string eventName, string parameter).
OnWaitingForInputUnityEventFired when the runner is waiting for player input (continue or choice).
OnVoiceStartVoiceStartEventFired when voice audio starts playing. Carries VoiceEventArgs. For lip sync integration.
OnVoiceEndVoiceEndEventFired when voice audio finishes. Carries VoiceEventArgs.

Properties

PropertyTypeDescription
StateDialogueStateCurrent state of the runner. Read-only.
IsRunningboolWhether a dialogue is currently running (State != Idle).
IsWaitingForInputboolWhether waiting for player input (WaitingForContinue or WaitingForChoice).
IsPausedboolWhether the dialogue is currently paused.
VariablesVariableStoreThe current dialogue's variable store (legacy; prefer SharedVariables).
CurrentSpeakerIdstringCharacter ID of the current speaker from the active text node.
CurrentListenerIdstringCharacter ID of the current listener.
SharedVariablesDialogueVariablesStatic. Shared variable system with global, actor, and local scopes. Access from anywhere via DialogueRunner.SharedVariables.

Methods

MethodSignatureDescription
StartDialoguevoid StartDialogue()Starts the assigned dialogue field.
StartDialoguevoid StartDialogue(DialogueAsset asset)Starts a specific dialogue asset at the default entry point.
StartDialoguevoid StartDialogue(DialogueAsset asset, string entryPointName)Starts a specific dialogue asset at a named entry point. Pass null or "" for default.
Stopvoid Stop()Stops the current dialogue. Fires OnDialogueEnd.
Continuevoid Continue()Advances to the next node when waiting for continue, skips typewriter when typing, or skips wait when waiting.
Pausevoid Pause()Pauses the dialogue runner and all audio.
Resumevoid Resume()Resumes a paused dialogue.
SelectChoicevoid SelectChoice(int index)Selects a choice by its index. Only valid when State == WaitingForChoice.
SkipTypewritervoid SkipTypewriter()Immediately shows the full text, skipping the typewriter effect.
GetVariable<T>T GetVariable<T>(string name, T defaultValue = default)Gets a variable value from the legacy Variables store.
SetVariable<T>void SetVariable<T>(string name, T value)Sets a variable value in the legacy Variables store.
SendSignalvoid SendSignal(string signalName)Sends a named signal to resume a waiting Signal node. Call from game code.
WasNodeVisitedbool WasNodeVisited(string nodeGuid)Checks if a specific node in the current dialogue has been visited (requires DialogueCraftPersistence).
GetPlayCountint GetPlayCount()Gets the number of times the current dialogue has been played.
GetVariablesJsonstring GetVariablesJson()Exports the current variable state as a JSON string for custom saving.
LoadVariablesJsonvoid LoadVariablesJson(string json)Loads variable state from a JSON string.
GetStateSnapshotDialogueStateSnapshot GetStateSnapshot()Captures the current dialogue state for mid-dialogue saves. Returns null if no dialogue is running.
RestoreFromSnapshotbool RestoreFromSnapshot(DialogueStateSnapshot snapshot)Restores dialogue state from a snapshot. Returns true on success.

DialogueState Enum

public enum DialogueState
{
Idle, // No dialogue running
Running, // Processing nodes
Typing, // Typewriter effect in progress
Waiting, // Waiting for a timed delay or sequence
WaitingForContinue, // Text displayed, awaiting player continue
WaitingForChoice, // Choices displayed, awaiting selection
WaitingForVoice // Voice audio playing, awaiting completion
}

DialogueAsset

namespace DialogueCraft
[CreateAssetMenu(fileName = "NewDialogue", menuName = "CraftWorks/DialogueCraft/Dialogue")]
public class DialogueAsset : ScriptableObject

A ScriptableObject containing a complete conversation graph. Each dialogue asset has its own graph, local variables, and cast of participants.

Serialized Fields

FieldTypeDefaultDescription
dialogueIdstringAsset nameUnique identifier for this dialogue. Auto-set from asset name.
descriptionstring""Description for reference (shown in editor).
tagsList<string>[]Tags for organizing dialogues (e.g., "Chapter 1", "Tutorial").
variablesList<DialogueVariable>[]Local variables scoped to this dialogue. Override globals.
graphDialogueGraphAuto-createdThe dialogue graph containing all nodes and connections.

Properties

PropertyTypeDescription
ParticipantIdsIReadOnlyList<string>Character IDs of the dialogue's cast.
ParticipantCountintNumber of participants in the cast.

Methods

MethodSignatureDescription
CreateVariableStoreVariableStore CreateVariableStore()Creates a new VariableStore seeded with global variables then local overrides.
GetEntryNodeDialogueNodeData GetEntryNode()Gets the default entry node of this dialogue.
GetCharacterCharacterData GetCharacter(string nameOrId)Gets a character by name or ID from DialogueCraftSettings.Characters.
GetVariableDialogueVariable GetVariable(string name)Gets a variable definition (local first, then global).
GetVariableWithScope(DialogueVariable, VariableScope) GetVariableWithScope(string name)Gets a variable and its scope (local or global).
GetVariableNamesstring[] GetVariableNames()Gets all variable names (global + local combined).
GetParticipantsList<CharacterData> GetParticipants()Gets all participant CharacterData objects.
HasParticipantbool HasParticipant(string characterId)Checks if a character is in the cast.
AddParticipantbool AddParticipant(string characterId)Adds a character to the cast. Returns false if already present or not in database.
RemoveParticipantbool RemoveParticipant(string characterId)Removes a character from the cast.
ClearParticipantsvoid ClearParticipants()Clears all participants.

DialogueGraph

namespace DialogueCraft
[Serializable]
public class DialogueGraph

Serialized graph data for a dialogue. Contains all nodes, connections, and groups.

Fields

FieldTypeDescription
entryNodeGuidstringGUID of the default entry node.
nodesList<DialogueNodeData>All nodes in the graph (uses [SerializeReference]).
connectionsList<NodeConnection>All connections between nodes.
groupsList<GroupData>Visual groups for organizing nodes.

Methods

MethodSignatureDescription
CreateDefaultstatic DialogueGraph CreateDefault()Creates a new empty graph with a default entry node.
GetNodeDialogueNodeData GetNode(string guid)Gets a node by its GUID.
GetEntryNodeDialogueNodeData GetEntryNode()Gets the default entry node.
GetEntryNodeEntryNodeData GetEntryNode(string entryPointName)Gets an entry node by name. Falls back to default.
GetEntryPointNamesList<string> GetEntryPointNames()Gets all entry point names (always includes "default").
GetNodeByLabelDialogueNodeData GetNodeByLabel(string label)Gets a node by its label string.
GetAllLabelsList<string> GetAllLabels()Gets all node labels in the graph.
GetConnectionsFromList<NodeConnection> GetConnectionsFrom(string nodeGuid)Gets all outgoing connections from a node.
GetConnectionsToList<NodeConnection> GetConnectionsTo(string nodeGuid)Gets all incoming connections to a node.
GetNextNodeDialogueNodeData GetNextNode(string nodeGuid, string portId = "output")Gets the node connected to a specific output port.
GetConnectedNodesList<DialogueNodeData> GetConnectedNodes(string nodeGuid)Gets all nodes connected to a node's outputs.
AddNodevoid AddNode(DialogueNodeData node)Adds a node to the graph. Prevents duplicates by GUID.
RemoveNodevoid RemoveNode(string nodeGuid)Removes a node and all its connections.
AddConnectionvoid AddConnection(string fromGuid, string fromPort, string toGuid, string toPort)Adds a connection between two nodes.
RemoveConnectionvoid RemoveConnection(string fromGuid, string fromPort, string toGuid, string toPort)Removes a specific connection.

Characters

CharacterData

namespace DialogueCraft
[Serializable]
public class CharacterData

Data for a single character stored in the CharacterDatabase. This is serializable data, not a ScriptableObject. Includes identity, typewriter voice settings (Unity + FMOD), and custom actor fields.

Fields

FieldTypeDefaultDescription
idstringUnique character identifier.
displayNamestringName shown in dialogue UI.
nameColorColorColor.whiteColor for the character's name.
portraitSpritenullDefault portrait sprite.
descriptionstring""Character description (for editor/AI context).
tagsList<string>[]Tags for grouping (e.g., "NPC", "Villain", "Party").
fieldsList<ActorField>[]Custom per-character fields (e.g., Friendship, TimesVisited).
typewriterModeTypewriterModeSingleHow typewriter sounds are selected.
typewriterSoundAudioClipnullSound for Single mode.
typewriterSoundsAudioClip[]nullSound pool for Random mode.
vowelSoundsAudioClip[]nullVowel sounds for VowelConsonant mode.
consonantSoundsAudioClip[]nullConsonant sounds for VowelConsonant mode.
letterSoundsAudioClip[26]new[26]Per-letter sounds for PerLetter mode (index 0=a, 25=z).
typewriterPitchfloat1.0Pitch multiplier. Range: 0.5--2.0.
typewriterPitchVariationfloat0.05Random pitch variation. Range: 0.0--0.3.
typewriterVolumefloat1.0Volume. Range: 0.0--1.0.
typewriterFmodEventPathstring""FMOD event path for Single mode.
typewriterFmodEventPathsstring[]nullFMOD event paths for Random mode.
typewriterFmodVowelPathsstring[]nullFMOD vowel paths for VowelConsonant mode.
typewriterFmodConsonantPathsstring[]nullFMOD consonant paths for VowelConsonant mode.
typewriterFmodLetterPathsstring[26]new[26]FMOD per-letter paths for PerLetter mode.

Methods

MethodSignatureDescription
GetFieldActorField GetField(string fieldName)Gets a field definition by name.
HasFieldbool HasField(string fieldName)Checks if a field exists.
AddFieldActorField AddField(string fieldName, VariableType type)Adds a new field.
RemoveFieldbool RemoveField(string fieldName)Removes a field by name.
GetFieldNamesstring[] GetFieldNames()Gets all field names.
GetTagsDisplaystring GetTagsDisplay()Gets tags as a comma-separated string.
HasTagbool HasTag(string tag)Checks if the character has a specific tag.

TypewriterMode Enum

public enum TypewriterMode
{
Single, // One sound with pitch variation
Random, // Pick randomly from a pool
VowelConsonant, // Different sounds for vowels vs consonants
PerLetter // Unique sound per letter a-z (Animal Crossing style)
}

CharacterDatabase

namespace DialogueCraft
[CreateAssetMenu(fileName = "CharacterDatabase", menuName = "CraftWorks/DialogueCraft/Character Database")]
public class CharacterDatabase : ScriptableObject

Project-wide database of all characters. One per project, referenced in DialogueCraftSettings.

Properties

PropertyTypeDescription
CharactersIReadOnlyList<CharacterData>All characters in the database.

Methods

MethodSignatureDescription
GetCharacterCharacterData GetCharacter(string characterId)Gets a character by ID.
GetCharacterByNameCharacterData GetCharacterByName(string displayName)Gets a character by display name.
AddCharacterCharacterData AddCharacter(string displayName)Creates and adds a new character. Returns the new CharacterData.
AddCharactervoid AddCharacter(CharacterData character)Adds a pre-configured character. Auto-generates ID if empty.
RemoveCharacterbool RemoveCharacter(string characterId)Removes a character by ID.
ResolveCharacterCharacterData ResolveCharacter(string nameOrId)Resolves a name or ID. Tries exact ID, then case-insensitive name with underscores treated as spaces.
IndexOfint IndexOf(CharacterData character)Gets the index of a character.

ActorField

namespace DialogueCraft
[Serializable]
public class ActorField

Defines a custom field on a character/actor. Fields persist across dialogues and are accessible via {Actor.CharacterID.FieldName} in text or DialogueRunner.SharedVariables.Actor("id").GetValue<T>("field") in code.

Fields

FieldTypeDefaultDescription
namestringField name (e.g., "Friendship", "TimesVisited").
descriptionstring""Description of what this field tracks.
typeVariableTypeIntField data type.
intValueint0Default integer value.
floatValuefloat0fDefault float value.
boolValueboolfalseDefault boolean value.
stringValuestring""Default string value.

Methods

MethodSignatureDescription
GetDefaultValueobject GetDefaultValue()Returns the default value as a boxed object based on type.
GetDefaultValueStringstring GetDefaultValueString()Returns the default value formatted for display.
GetTypeLabelstring GetTypeLabel()Returns the short type label ("int", "float", "bool", "string").

Variables

For the full DialogueVariables, VariableStore, and event types API, see the source content which continues with detailed documentation of all variable classes, persistence classes (DialogueCraftPersistence, DialogueCraftSaveData), localization classes (LocalizationManager), audio interfaces (IDialogueAudioProvider, AudioProviderManager, DialogueAudioManager), AI classes (DialogueCraftAI), UI classes (IDialogueUI, DialogueUIBase), interaction classes (DialogueTrigger, DialogueInteractable), bark classes (Barker, BarkData), and common enums.

Please refer to the individual guide pages for usage details:

Common Enums

public enum VariableType { String, Int, Float, Bool }

public enum VariableScope { Global, Actor, Local }

public enum VariableOperation { Set, Add, Subtract, Multiply, Divide, Toggle, Append }

public enum AudioSourceType { Unity, FMOD }

public enum AudioChannel { Music, Ambient, Voice, SFX }

public enum LocalizationProviderType { BuiltIn, LocalizeCraft, UnityLocalization }