DialogueController is the base class for all dialogue systems in Luna UI. It provides text reveal animations, audio integration, and text effects coordination.
DialogueController requires a DialogueAudio component on the same GameObject for audio playback.
| Mode | Description |
|---|---|
| VertexReveal | Recommended. Uses vertex manipulation for smooth reveal with text effects |
| Default | Legacy mode. Shows text character by character |
| Instant | Shows all text immediately with text effects active |
| Setting | Description |
|---|---|
| Skip Chars | Characters to skip during reveal (default: space) |
| Stop Chars | Characters that trigger a pause (default: ., ,, !, ?) |
| Text Animation Mode | The reveal mode to use |
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");
}
}Returns true if text is currently being revealed.
if (_dialogueController.IsPlaying)
{
// Text is still being revealed
}Plays text with optional skip behavior.
public bool Continue(string text, bool skipCurrent)| Parameter | Description |
|---|---|
| text | The text to display (can include text effect tags) |
| skipCurrent | If 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:
// 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);Immediately completes the current text animation and shows the full text.
public void EndCurrent()Virtual method called during Awake. Override in derived classes to set up additional UI elements.
public virtual void InitializeUI()| Event | Description |
|---|---|
| OnTextStart | Fired when text begins playing |
| OnTextComplete | Fired when text finishes (either naturally or via EndCurrent) |
DialogueController automatically parses and applies text effects:
// 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
);The DialogueAudio component handles audio playback during text reveal.
| Setting | Description |
|---|---|
| Letter | AudioClip played for each character |
| Pause | AudioClip played for punctuation pauses |
public void PlayLetter() // Play letter sound
public void PlayPause() // Play pause soundThe DialogueController expects a Label with name "Speech":
<ui:UXML xmlns:ui="UnityEngine.UIElements">
<ui:Label name="Speech" />
</ui:UXML>DialogueController serves as the base for specialized dialogue implementations:
VertexReveal mode for the best visual quality with text effectsskipCurrent parameter is useful for implementing "click to skip" functionalityOnTextComplete to know when to show "continue" promptsSettings
Theme
Light
Contrast
Material
Dark
Dim
Material Dark
System
Sidebar(Light & Contrast only)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction