Luna UI's Text Effects system allows you to add dynamic animations to text using rich text tags. The system provides 12 different animation effects that can be applied to text using simple XML-like syntax.

Text Effects

Features

  • 12 Different Effects: Pendulum, Dangle, Fade, Rainbow, Rotate, Bounce, Slide, Swing, Wave, Increase Size, Shake, and Wiggle
  • Rich Text Tags: Simple XML-like syntax for easy integration
  • Automatic Integration: Works seamlessly with DialogueController
  • Standalone Component: Can be used independently with TextEffectComponent
  • Effect Nesting: Combine multiple effects for complex animations
  • Text Reveal Support: Effects coordinate with text reveal animations

Quick Start

Basic Syntax

All text effects use the same basic syntax:

xml
<effectname parameter="value">Your text here</effectname>

Example:

xml
<wave startoffset="-10" endoffset="10">Wavy Text</wave>

Simple Example

xml
Hello <rainb durationperchar="1.0">World</rainb>!

This creates a rainbow effect on the word "World" while keeping "Hello" and "!" normal.

Usage with Dialogue System

The Dialogue System automatically supports text effects. Simply include effect tags in your dialogue text, and they will be parsed and applied automatically.

Setup

No additional setup is required! The DialogueController automatically:

  1. Parses effect tags from dialogue text
  2. Initializes text effects
  3. Coordinates effects with text reveal
  4. Removes tags from displayed text

Example with Ink Dialogue

ink
Character: This text has a <pend startangle="-20" endangle="20">pendulum</pend> effect! Character: Watch this <rainb durationperchar="1.0">rainbow</rainb> text cycle through colors!

Example with Code

csharp
string dialogueText = "This text will <shake maxxamplitude=\"5\" maxyamplitude=\"5\">shake</shake>!"; dialogueController.Continue(dialogueText, false);

Usage with TextEffectComponent

To use text effects on static labels (not in dialogue), use the TextEffectComponent.

Setup Steps

  1. Add TextEffectComponent to your GameObject

    • Select the GameObject with your UIDocument
    • Add Component → TextEffectComponent
  2. Configure the Component

    • UIDocument: Reference to your UIDocument (auto-detected if on same GameObject)
    • Label Selector: Configure which labels should have effects applied
      • Type: Select "Name" to target by name, "Class" for USS classes, etc.
      • Value: Enter the name/class/value to match
  3. Add Effect Tags to Your Label Text

    • Set the label's text property with effect tags
    • Effects are applied automatically when the component starts

Example in Code

csharp
using UnityEngine; using UnityEngine.UIElements; using CupkekGames.Luna.TextAnimation; public class MyUI : MonoBehaviour { private UIDocument uiDocument; private TextEffectComponent effectComponent; void Start() { uiDocument = GetComponent<UIDocument>(); effectComponent = GetComponent<TextEffectComponent>(); // Set text with effects Label titleLabel = uiDocument.rootVisualElement.Q<Label>("TitleLabel"); titleLabel.text = "Welcome to <rainb durationperchar=\"1.0\">Luna UI</rainb>!"; // Apply effects (or they'll be applied automatically in Start) effectComponent.ApplyEffects(); } }

Dynamic Text Updates

When you change a label's text at runtime, call ApplyEffects() to re-apply effects:

csharp
// Update text myLabel.text = "New <wave>text</wave> with effects"; // Re-apply effects textEffectComponent.ApplyEffects();

Available Effects

Pendulum (<pend>)

Creates a swinging pendulum motion where text rotates around its top center point.

ParameterDefaultDescription
startangle-15Starting rotation angle in degrees
endangle15Ending rotation angle in degrees
damping0.05Damping factor (0 = no damping)
centeroffsetx0Horizontal offset of rotation center
centeroffsety-40Vertical offset of rotation center
durationperchar0.5Duration of animation per character
animationtypepingpongAnimation type
xml
<pend startangle="-20" endangle="20">Swinging Text</pend>

Dangle (<dangle>)

Creates a spring-like dangle motion where text oscillates vertically with gravity effects.

ParameterDefaultDescription
startoffset-10Starting vertical offset in pixels
endoffset10Ending vertical offset in pixels
speed1.0Speed of oscillation
gravity9.8Gravity effect strength
damping0.9Damping factor (0-1)
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
xml
<dangle startoffset="-12" endoffset="12">Dangling Text</dangle>

Fade (<fade>)

Smoothly fades text opacity between minimum and maximum values.

ParameterDefaultDescription
startalpha0.0Starting alpha (0-1)
endalpha1.0Ending alpha (0-1)
durationperchar0.5Duration of fade cycle
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<fade startalpha="0.3" endalpha="1.0">Fading Text</fade>

Rainbow (<rainb>)

Cycles text through colors with multiple color modes.

ParameterDefaultDescription
durationperchar0.5Duration of color cycle
colormode00=Rainbow, 1=Gradient, 2=Two Colors, 3=Alpha Only
speed1.0Speed of color cycling (Rainbow mode)
saturation1.0Color saturation 0-1
brightness1.0Color brightness 0-1
color1-4-Custom colors for Gradient/TwoColors modes
startalpha0Starting alpha for Alpha mode
endalpha1Ending alpha for Alpha mode

Rainbow Mode:

xml
<rainb durationperchar="1.0">Rainbow Text</rainb>

Custom Gradient:

xml
<rainb colormode="1" color1="FF0000" color2="00FF00" color3="0000FF">Gradient</rainb>

Two Colors:

xml
<rainb colormode="2" color1="red" color2="blue">Two Colors</rainb>

Rotate (<rot>)

Rotates text around its center point.

ParameterDefaultDescription
startangle-15Starting rotation angle
endangle15Ending rotation angle
loop0If > 0.5, continuous rotation
centeroffsetx0Horizontal offset of center
centeroffsety0Vertical offset of center
durationperchar0.5Duration per character
animationtypepingpongAnimation type
xml
<rot startangle="0" endangle="360" animationtype="loop" loop="1" durationperchar="2.0">Rotating</rot>

Bounce (<bounce>)

Creates an upward bouncing motion with decay.

ParameterDefaultDescription
startoffset0Starting vertical offset
endoffset-10Ending vertical offset (negative = up)
decay0.8Decay factor (0-1)
speed2.0Bounce frequency
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
xml
<bounce startoffset="0" endoffset="-10" decay="0">Bouncing Text</bounce>

Slide (<slideh>)

Slides text horizontally or vertically.

ParameterDefaultDescription
startoffsetx-10Starting horizontal offset
endoffsetx0Ending horizontal offset
startoffsety0Starting vertical offset
endoffsety0Ending vertical offset
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<slideh startoffsetx="-10">Sliding Text</slideh>

Swing (<swing>)

Creates an arc-like swinging motion combining horizontal and vertical movement.

ParameterDefaultDescription
startangle-15Starting swing angle
endangle15Ending swing angle
amplitude20.0Maximum swing distance
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<swing startangle="-15" endangle="15">Swinging Text</swing>

Wave (<wave>)

Creates a smooth sine wave motion that propagates through the text.

ParameterDefaultDescription
startoffset-10Starting vertical offset
endoffset10Ending vertical offset
frequency1.0Wave frequency
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<wave startoffset="-10" endoffset="10" frequency="1.5">Wavy Text</wave>

Increase Size (<incr>)

Pulsates text size between minimum and maximum scale values.

ParameterDefaultDescription
startscale0.8Starting scale (1.0 = normal)
endscale1.2Ending scale
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<incr startscale="0.8" endscale="1.2">Pulsing Text</incr>

Shake (<shake>)

Applies random shaking motion to each character independently.

ParameterDefaultDescription
maxxamplitude5.0Maximum horizontal shake
maxyamplitude5.0Maximum vertical shake
minwait0.1Minimum time between updates
maxwait0.15Maximum time between updates
speed10.0Frequency of updates
xml
<shake maxxamplitude="5" maxyamplitude="5">Shaking Text</shake>

Wiggle (<wiggle>)

Creates small, smooth wiggling motions using sine and cosine waves.

ParameterDefaultDescription
startoffsetx-3Starting horizontal offset
startoffsety-2Starting vertical offset
endoffsetx3Ending horizontal offset
endoffsety2Ending vertical offset
frequency2.0Wiggle frequency
durationperchar0.5Duration per character
timebetweenchars0.05Delay between characters
animationtypepingpongAnimation type
xml
<wiggle startoffsetx="-3" startoffsety="-2" endoffsetx="3" endoffsety="2">Wiggling Text</wiggle>

Common Parameters

Timing Parameters

ParameterDefaultDescription
durationperchar0.5Duration of animation per character in seconds
timebetweenchars0.05Delay between characters starting animation
nodelayforcharsfalseIf true, all characters start animating simultaneously

Animation Type

ValueDescription
pingpong / 0Oscillates back and forth (default)
loop / 1Loops continuously in one direction
onetime / 2Plays once from start to end
loopfixedduration / 3Loops with fixed duration

Combining Effects

You can nest effects to combine multiple animations on the same text.

Basic Nesting

xml
<wave durationperchar="0.67"><rainb durationperchar="1.0">Wavy Rainbow</rainb></wave>

Multiple Nested Effects

xml
<shake maxxamplitude="3" maxyamplitude="3"> <wave durationperchar="0.67">Shaky Wavy</wave> </shake>

Complex Combinations

Animated Logo:

xml
<wave durationperchar="0.5"> <rainb colormode="1" color1="FF0000" color2="00FF00" color3="0000FF">My Game</rainb> </wave>

Dramatic Text:

xml
<shake maxxamplitude="4" maxyamplitude="4"> <incr startscale="0.7" endscale="1.3">WARNING!</incr> </shake>

Note: Inner effects are applied first, then outer effects. Be careful with conflicting transformations and performance with many nested effects.

Example Use Cases

Dialogue

csharp
// Emotional speech dialogueController.Continue("I'm <shake maxxamplitude=\"3\" maxyamplitude=\"3\">angry</shake>!", false); dialogueController.Continue("This is <rainb durationperchar=\"1.0\">amazing</rainb>!", false); dialogueController.Continue("I'm <bounce endoffset=\"-10\">excited</bounce>!", false);

UI Labels

Attention-Grabbing Button:

xml
<incr startscale="0.9" endscale="1.1">Click Me!</incr>

Status Indicator:

xml
Status: <fade startalpha="0.3" endalpha="1.0">Online</fade>

Troubleshooting

Effects Not Appearing

  1. Check that effect tags are properly closed: <effect>text</effect>
  2. Verify parameter names are correct (case-insensitive)
  3. For TextEffectComponent: Ensure the component targets the correct label
  4. Call ApplyEffects() after changing text at runtime

Effects Too Fast/Slow

  1. Adjust durationperchar - lower = faster, higher = slower
  2. Adjust timebetweenchars for wave propagation speed

Performance Issues

  1. Limit the number of nested effects
  2. Use simpler effects (fade, rainbow) instead of complex ones (shake, wiggle)
  3. Avoid applying effects to very long text strings

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