Dialogue Controller

DialogueController is the base class for all dialogue systems in Luna UI. It provides text reveal animations, audio integration, and text effects coordination.

Features

  • Text Reveal Animation: Character-by-character text reveal with configurable timing
  • Audio Integration: Automatic audio playback for letters and punctuation pauses
  • Text Effects Support: Full integration with the Text Effects system
  • Multiple Animation Modes: Choose from VertexReveal, Default, or Instant modes
  • Event System: Events for text start and completion

Components

DialogueController requires a DialogueAudio component on the same GameObject for audio playback.

Animation Modes

ModeDescription
VertexRevealRecommended. Uses vertex manipulation for smooth reveal with text effects
DefaultLegacy mode. Shows text character by character
InstantShows all text immediately with text effects active

Inspector Settings

SettingDescription
Skip CharsCharacters to skip during reveal (default: space)
Stop CharsCharacters that trigger a pause (default: ., ,, !, ?)
Text Animation ModeThe reveal mode to use

Basic Usage

csharp
using UnityEngine; using CupkekGames.Luna; public class MyDialogue : MonoBehaviour { [SerializeField] private DialogueController _dialogueController; private void Start() { // Subscribe to events _dialogueController.OnTextStart += OnDialogueStart; _dialogueController.OnTextComplete += OnDialogueComplete; } public void ShowDialogue(string text) { // Continue with text, don't skip current if playing _dialogueController.Continue(text, skipCurrent: false); } public void SkipToEnd() { // End current text animation immediately _dialogueController.EndCurrent(); } private void OnDialogueStart() { Debug.Log("Dialogue started"); } private void OnDialogueComplete() { Debug.Log("Dialogue complete"); } }

Public Properties

IsPlaying

Returns true if text is currently being revealed.

csharp
if (_dialogueController.IsPlaying) { // Text is still being revealed }

Public Methods

Continue

Plays text with optional skip behavior.

csharp
public bool Continue(string text, bool skipCurrent)
ParameterDescription
textThe text to display (can include text effect tags)
skipCurrentIf true and text is playing, skips to new text. If false, completes current text first.

Returns: true if new text started playing, false if current text was completed instead.

Example:

csharp
// First call starts "Hello World" _dialogueController.Continue("Hello World", false); // If called while playing, this completes "Hello World" and returns false bool started = _dialogueController.Continue("Next line", false); // With skipCurrent: true, immediately starts new text _dialogueController.Continue("Skipped to this!", true);

EndCurrent

Immediately completes the current text animation and shows the full text.

csharp
public void EndCurrent()

InitializeUI

Virtual method called during Awake. Override in derived classes to set up additional UI elements.

csharp
public virtual void InitializeUI()

Events

EventDescription
OnTextStartFired when text begins playing
OnTextCompleteFired when text finishes (either naturally or via EndCurrent)

Using Text Effects

DialogueController automatically parses and applies text effects:

csharp
// Text effects are automatically parsed and applied _dialogueController.Continue( "This is <shake maxxamplitude=\"5\">scary</shake> stuff!", false ); // Rainbow effect _dialogueController.Continue( "Look at this <rainb durationperchar=\"1.0\">magical</rainb> text!", false );

DialogueAudio Component

The DialogueAudio component handles audio playback during text reveal.

Inspector Settings

SettingDescription
LetterAudioClip played for each character
PauseAudioClip played for punctuation pauses

Public Methods

csharp
public void PlayLetter() // Play letter sound public void PlayPause() // Play pause sound

UXML Structure

The DialogueController expects a Label with name "Speech":

xml
<ui:UXML xmlns:ui="UnityEngine.UIElements"> <ui:Label name="Speech" /> </ui:UXML>

Derived Classes

DialogueController serves as the base for specialized dialogue implementations:

Tips

  • Use VertexReveal mode for the best visual quality with text effects
  • The skipCurrent parameter is useful for implementing "click to skip" functionality
  • Subscribe to OnTextComplete to know when to show "continue" prompts
  • Text effect tags are automatically removed from the displayed text

Settings

Theme

Light

Contrast

Material

Dark

Dim

Material Dark

System

Sidebar(Light & Contrast only)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL