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
  • Actions Base Class
  • Attributes
  • DoAction Method
  • ✅ Done!
  1. Extra Customization via C#

Writing Custom Actions (C#)

PreviousWriting Custom Typewriters (C#)NextBest Practices

Last updated 7 months ago

Other than using , you can write your own via script (C#).


Actions Base Class

When creating a new class, inherit from Febucci.UI.Actions.ActionScriptableBase ().

public class CustomAction : ActionScriptableBase
{
    //[...]

Attributes

Since you’re creating a ScriptableObject, just like Events, make sure to add the needed attributes as well in order to instance and serialize them:

[CreateAssetMenu(fileName = "YourCustomAction", menuName = "Text Animator/Custom/YourCustomAction")]
[System.Serializable]
public class CustomAction : ActionScriptableBase
{
    //[...]

This way you’ll be able to create them from your Project Window.

DoAction Method

Then, all you need to do is overriding the “DoAction” method and write your code inside it.

Remember that actions pause the typewriter until they’re completed (for example, waiting for player input or until time has passed).

public override IEnumerator DoAction(ActionMarker action, TypewriterCore typewriter, TypingInfo typingInfo)
{
    //[...]
}
  • The action paramater has useful info about your tag, for example the ID or if there are any parameters that come with it (e.g. <playSound=02>).

  • The typewriter references the component that is currently performing the action

  • The typingInfo contains information such as the current typing speed (which you can modify) and time passed inside the typewriter.

Please refer to the Scripting API to have a complete view of the classes and more.


✅ Done!

Done! With this simple procedure, you can add any Custom Action you want.

P.S. Don’t forget to create your action ScriptableObject in the ProjectView, and add it to an actions Database.

built-in actions
Scripting API