Action Component

Dialogue System

Show sequential character dialogue with animated portraits and text — triggered by any UnityEvent. Optional decision panel lets players make choices that fire their own events.

No UI setup required
Typewriter, fade, and slide animations
Left and right character portraits
Player decision branching

Getting Started

Minimal setup

Add the component, fill in your lines, and wire a trigger. No Canvas or UI prefab needed — the dialogue system builds its own UI at runtime.

  1. 1
    Add ActionDialogueSequence to any GameObject
    Works on the NPC, a trigger zone, or any empty object. The UI is created at runtime and destroyed when the scene ends — you never see it in the Hierarchy during edit mode.
  2. 2
    Add your dialogue lines
    Expand the Dialogue Content section in the Inspector. Each Dialogue Line has: dialogueText, displayTime (seconds on screen), an optional characterImage (Sprite), and orientation (Left or Right). Add as many lines as you need.
  3. 3
    Wire a trigger to StartDialogue()
    Use any event source — InputTriggerZone, InputInteractionZone, a button, a key press. Call ActionDialogueSequence → StartDialogue(). To stop mid-sequence, call StopDialogue().
  4. 4
    (Optional) Enable playOnStart for cutscenes
    Check Play On Start to begin dialogue automatically when the scene loads — useful for opening cutscenes and intro sequences.
💡
Enable Click-Through for interactive feel
Check Enable Click Through to let players click (or press any key / gamepad A) to skip to the next line instead of waiting for displayTime. Recommended for most games — it keeps dialogue from feeling locked in.

Content

Dialogue lines

Each line in the array is a DialogueLine struct. Fill out as many as you need — they play in order from top to bottom.

FieldTypeDescription
dialogueTextstringThe text to display. Supports TextMeshPro rich text tags like <b>, <color=#…>, etc.
displayTimefloatHow long (seconds) this line stays on screen after finishing its entrance animation. With click-through enabled, players can advance early.
characterImageSpritePortrait image for this line. Leave empty for text-only lines. The previous portrait fades out between lines.
orientationLeft / RightWhich side of the screen the portrait appears on. Use Left for the player and Right for NPCs, or alternate per speaker.
🎨
Custom font and text color
Under Visual Settings, set textColor and optionally assign a customFont (TMP_FontAsset). These apply to all lines including decision buttons. Text size, alignment, and position are also adjustable there.

Dialogue Events

EventWhen it fires
onDialogueStartWhen StartDialogue() is called and playback begins
onDialogueCompleteAfter the last line (and decision, if enabled) finishes
onLineChangedEach time a new line begins — passes the line index (int)
onDecisionStartWhen the decision panel appears (after last dialogue line)

Presentation

Animation options

The defaults (slide-up portrait, typewriter text) look great without any changes. Adjust if you want a different feel — portrait and text animate independently.

Portrait
Image Animation
  • None — portrait appears instantly
  • Slide Up From Bottom — portrait slides up from below (default)
  • Slide In From Side — portrait slides in from its side of the screen
  • Fade In — portrait fades from transparent to opaque
  • Pop In — portrait scales up from zero with a bounce
Text
Text Animation
  • None — full text appears instantly
  • Aa
    Type On — typewriter effect, characters appear one at a time (default)
  • Fade In — full text fades from transparent
  • Slide Up From Bottom — full text slides upward into position

Key timing fields

FieldDefaultDescription
imageFadeInDuration0.2sHow long portrait entrance animation takes
imageFadeOutDuration0.2sHow long portrait exit animation takes between lines
slideDistance500Pixels the portrait travels during slide animations
charactersPerSecond30Typewriter speed. 20 = slow and dramatic, 60 = fast
textFadeInDuration0.2sDuration for text Fade In or Slide animation
Click-through skips the typewriter
When enableClickThrough is on and the typewriter is still running, the first click completes the current line instantly (shows all text). A second click advances to the next line. This is standard RPG behaviour — players who read fast aren't forced to wait.

Branching

Decision system

After the last dialogue line, display a panel of clickable choices. Each choice fires its own UnityEvent — wire them to anything: load a scene, spawn an item, start another dialogue.

  1. 1
    Enable the decision system
    Check Enable Decision in the Decision System (Optional) section. The panel appears only after the final dialogue line completes.
  2. 2
    Add your choices
    Each Decision Choice has choiceText (button label), an optional choiceImage (Sprite shown left of the text), and onChoiceSelected (the UnityEvent to fire when clicked).
  3. 3
    Wire each choice event
    Use onChoiceSelected like any UnityEvent — load a new scene, call a method, start a different ActionDialogueSequence, update a flag. After a choice is made, onDialogueComplete also fires.

Decision navigation

🎮
Works with mouse, keyboard, and gamepad
Players can click buttons with the mouse, use Up/Down arrows (or W/S) to highlight then Enter/Space to confirm, or use the D-pad / left stick and A button on gamepad. The first choice is highlighted by default.

For first-person scenes: assign the FP Controller field under Character Controller Integration. The cursor unlocks automatically while the decision panel is open, and re-locks when a choice is made.

Decision field reference

FieldDefaultDescription
enableDecisionfalseShow a choice panel after the last line
decisionChoices[ ]Array of DecisionChoice — each has choiceText, choiceImage, onChoiceSelected
decisionPanelPosition(0, -200)Center of the decision panel in screen-space pixels
decisionButtonSize(400, 100)Width × height of each choice button
decisionButtonSpacing20Vertical gap between buttons
decisionButtonOpacity0.9Background opacity of buttons (0 = transparent, 1 = solid)
decisionFontSize36Font size on choice buttons
fpControllerNoneAssign for FP scenes — auto-unlocks cursor during decisions

Common Setups

Recipes

NPC walk-up conversation
Player walks into range, dialogue starts
TriggerInputInteractionZone
On EnterStartDialogue()
enableClickThroughtrue
loopfalse
onDialogueCompleteany follow-up
Opening cutscene
Plays automatically when the scene loads
playOnStarttrue
enableClickThroughfalse
imageAnimationFadeIn
textAnimationTypeOn
onDialogueCompleteenable player movement
Decision: choose a path
Player picks a direction; loads different scenes
enableDecisiontrue
Choice A text"Go left"
Choice A eventLoadScene("Level1Left")
Choice B text"Go right"
Choice B eventLoadScene("Level1Right")
Hint / looping tutorial
Repeatable instructions that cycle on each trigger
looptrue
enableClickThroughtrue
TriggerInputTriggerZone onEnter
Stop triggeronExit → StopDialogue()
characterImageuse an icon sprite as portrait

Reference

Full field reference

Playback Settings

FieldDefaultDescription
playOnStartfalseBegin dialogue automatically when the scene starts
loopfalseLoop back to line 0 after the last line instead of completing
enableClickThroughfalseLet mouse click / any key / gamepad A advance or skip lines

Visual Settings

FieldDefaultDescription
backgroundImageNoneOptional full-screen background sprite (e.g. letterbox bars)
backgroundPosition / Size(0,0) / (1920,1080)Anchor and dimensions of the background image
leftPosition / rightPosition(-400,-100) / (400,-100)Screen-space anchor for left and right portraits
portraitSize(300,300)Width × height of portrait images
textPosition / textSize(0,-300) / (1200,200)Position and size of the dialogue text box
fontSize48TextMeshPro font size for all dialogue text
textAlignmentLeftTMP text alignment (Left, Center, Right, etc.)
textColorWhiteColor of dialogue and decision text
customFontNoneOverride the default TMP font with any TMP_FontAsset

Public Methods

MethodDescription
StartDialogue()Begin the sequence from line 0. Safe to call while already playing — restarts from the beginning.
StopDialogue()Immediately stop playback and hide the canvas.
NextDialogue()Skip the current typewriter or advance to the next line. Same as click-through, callable from code.
SetTypewriterSpeed(float)Change charactersPerSecond at runtime.
SetLoop(bool)Toggle loop mode at runtime.