Text Animator for Unity
More ToolsTutorialsDiscord✨ Get Text Animator ✨
2.X 🇬🇧
2.X 🇬🇧
  • ❤️Welcome
    • Text Animator for Unity
    • Features
    • Games Showcase
    • Quick Start
  • ✨effects
    • Add effects to your texts
      • Modifiers
      • Styles
      • Databases
    • Preview and Edit effects
      • Dynamic Scaling
      • Time Scale
    • Built-in effects list
    • Create your own effects
      • Create effects in the Inspector
        • Curve Effects
        • Composite Effects
      • Writing Custom Effects (C#)
  • ✏️typewriter
    • Show and hide letters dynamically
    • Play sounds when a letter is shown
    • Trigger Events when typing
    • Wait Actions when typing
  • 🤝Integrations
    • Integrated Plugins & Dialogues Systems
      • Dialogue System for Unity
      • Yarn Spinner
      • Ink
      • Game Creator 2
      • Unity Localization Package
      • Playmaker
      • Unity Visual Scripting
      • Naninovel
    • How to manually integrate Text Animator
  • Extra Customization via C#
    • Writing Custom Typewriters (C#)
    • Writing Custom Actions (C#)
  • Other
    • Best Practices
    • Requirements & Limitations
    • Frequently Asked Questions
    • Support
    • Changelog
      • 2.X
      • Upgrading from 1.X to 2.X
      • 1.X
    • Scripting API
Powered by GitBook
On this page
  • Overview
  • Formatting
  • Parameters
  • Listening to events
  1. typewriter

Trigger Events when typing

PreviousPlay sounds when a letter is shownNextWait Actions when typing

Last updated 7 months ago

Events are special tags that let you send messages (string) to any listener script, once the typewriter has reached a specific part of the text. (For this reason, events work only if the typewriter is enabled)


Overview

You can write events in your text by using rich text tags.

Formatting

Event’s messages are preceded by a question mark, like this: <?eventMessage>.

Example: To call an event named ‘shakeCamera’, write: <?shakeCamera>

  • 👍🏻 An event can have any kind of tag, including built-in effect’s ones.

  • ⚠️ Events are case sensitive. Writing <?camshake> is not the same as writing <?camShake>. Be careful! (or use the string.ToLower() method in your scripts to account for that.)

Parameters

Events can have one or multiple parameters (starting with the = sign for the first, and then separating the others with a comma ,), to allow you to send multiple data to your scripts.

  • One parameter: <?eventID=parameter1>, will result in a message “eventID” and one parameter “parameter1”.

  • Multiple parameters: <?eventID=p1,p2>, will result in a message “eventID” and parameters “p1” and “p2”.


Listening to events

Example:


//Inside your script

public Febucci.UI.Core.TypewriterCore typewriter;

//Adds and removes listening to callback
void OnEnable() => typewriter.onMessage.AddListener(OnTypewriterMessage);
void OnDisable() => typewriter.onMessage.RemoveListener(OnTypewriterMessage);

//Does stuff based on event
void OnTypewriterMessage(Febucci.UI.Core.Parsing.EventMarker eventMarker)
{
    switch (eventMarker.name)
    {
        case "something":
            // do something
            break;
    }
}

👍🏻 Note how the “message” string has no ‘<‘, ‘?’ and ‘>’ characters, but only contains the message.

The scripts that you want to listen from events/messages must subscribe to the onMessage callback inside the Typewriter class. ().

You can find the , for example to get all the parameters of the event (if any).

✏️
Scripting Api
EventMarker API here
Scene 'Example 3 - Events'
textanimatorgif2febucci