Dialogue Speaker

Overview

DialogueSpeaker is a ScriptableObject that defines everything the dialogue system needs to know about a character: their display name, portrait, name and text colours, optional voice audio, typewriter speed override, and an optional Cinemachine virtual camera to activate when they speak.

Each SimpleDialogueNode and ChoiceDialogueNode holds a reference to one DialogueSpeaker asset. When the dialogue UI displays a line it reads from that asset to populate the name label, portrait image, text colour, and text speed — and optionally activates the speaker's Cinemachine camera.

Create via: Assets → Create → Malbers Quest Forge → Dialogue → Speaker

Can also be created inline from any node that accepts a Speaker field using the + button beside the Speaker field in the graph editor.


Properties

Speaker Identity

Property
Type
Default
Description

Speaker Name

String

"Character"

The display name shown in the dialogue UI name label. A warning is shown in the Inspector if this is left empty.

Portrait

Sprite

None

The avatar or bust image displayed in the dialogue UI alongside the name. Optional.

Name Color

Color

White

Tint applied to the name label text in the dialogue UI.

Audio Settings

Property
Type
Default
Description

Voice Clip

AudioClip

None

Audio clip played when this speaker delivers a line. Optional — dialogue is silent if unassigned.

Voice Pitch

Float (0.8 – 1.2)

1.0

Pitch multiplier applied when the voice clip is played. Use values below 1.0 for deeper voices, above 1.0 for higher voices.

Text Settings

Property
Type
Default
Description

Text Color

Color

White

Tint applied to the dialogue body text when this speaker is active.

Custom Text Speed

Float (0 – 100)

0

Typewriter characters-per-second override for this speaker. Set to 0 to fall back to the DialogueManager's global text speed.

Camera Settings

Both fields use Malbers reference types (TransformReference / GameObjectReference), which each support either a direct inline object assignment or a linked ScriptableObject variable (TransformVar / GameObjectVar).

Property
Type
Description

Camera Target

TransformReference

A Transform the gameplay camera can be directed to focus on when this speaker is active. Used by the FocusOnSpeaker action in CinemachineDialogueNode.

Cinemachine Camera

GameObjectReference

A Cinemachine Virtual Camera GameObject to activate when this speaker talks. This is the camera targeted by the Focus Camera on Speaker toggle on SimpleDialogueNode and ChoiceDialogueNode.

Priority: If both are assigned, cinemachineCamera takes precedence for camera activation. cameraTarget is only used when no Cinemachine camera is configured.


Public API

Member
Returns
Description

GetTextSpeed(float defaultSpeed)

float

Returns customTextSpeed if it is greater than 0; otherwise returns defaultSpeed. Called by the DialogueManager when displaying a line to determine the active typewriter rate.

HasCustomCamera()

bool

Returns true if cinemachineCamera.Value is not null. Used by nodes to decide whether to activate a speaker camera.


Inspector Preview

The Inspector's Speaker Preview panel renders a live representation of how the speaker will appear in the dialogue UI:

  • Name — drawn in bold using nameColor.

  • Portrait — displayed at 64 × 64 pixels if assigned.

  • Sample text"This is how my dialogue text will appear in-game." drawn in textColor with word wrap.

The preview updates immediately as you change name, colours, or portrait, without entering Play Mode.


How Nodes Use a DialogueSpeaker

When a SimpleDialogueNode or ChoiceDialogueNode is processed at runtime:

  1. Name label — set to speakerName, coloured with nameColor.

  2. Portrait — set to portrait if assigned; portrait panel hidden if null.

  3. Dialogue text — coloured with textColor; typewriter speed resolved via GetTextSpeed(defaultSpeed).

  4. VoicevoiceClip played at voicePitch if assigned.

  5. Camera — if Focus Camera on Speaker is enabled on the node and HasCustomCamera() returns true, the camera on cinemachineCamera is activated (priority raised) for the duration of that node.


Usage Tips

  • One asset per character — a single DialogueSpeaker is shared across every node in every dialogue graph that features that character. Changing the name or portrait in one place updates all uses automatically.

  • Inline creation — the + button on any Speaker field in the graph editor creates and saves a new asset to the project without leaving the graph editor window.

  • Colour-coded cast — assigning a distinct nameColor per character (e.g. cyan for the player, gold for the quest giver) gives players an instant visual cue about who is speaking even before reading the name label.

  • Per-character typewriter speed — set a faster customTextSpeed for excitable or quick-talking characters and a slower one for slow, deliberate speakers, without touching the DialogueManager's global setting.

  • Shared vs. instanced cameras — assign the Cinemachine camera as a GameObjectReference using a direct constant value for a dedicated NPC camera, or use a GameObjectVar if the same speaker asset is used across multiple scenes where the camera reference differs.

  • Voiceless speakers — leaving voiceClip blank is perfectly valid. The Inspector will note "dialogue will be silent" but raises no error, so narrators or text-only characters need no special setup.

Last updated