Skip to content

A utility to create typing effect for TextMeshPro. Seamlessly support Ruby (Furigana) thanks to RubyTextMeshPro.

License

Notifications You must be signed in to change notification settings

kiraio-moe/TMP_Typewriter_With_Ruby

 
 

Repository files navigation

TMP_Typewriter (With_Ruby)

TMP_Typewriter is a utility to create typing effect for TextMeshPro by utilizing DOTween functionality. Seamlessly support Ruby (Furigana) thanks to RubyTextMeshPro.

Features

  • Support Rich Text tags.
  • Skippable.
  • Can pause and resume.
  • Can delay typing effect.
  • OnComplete callback.
  • Compatible with CharTweener.

How to Use

  • Download DOTween from DOTween official website then import.

  • Install the modified RubyTextMeshPro via UPM Git URL:

    https://github.com/kiraio-moe/RubyTextMeshPro.git?path=Assets/RubyTextMeshPro

    or .unitypackage from RubyTextMeshPro Releases.

  • Install TMP_Typewriter_With_Ruby via UPM Git URL:

    https://github.com/kiraio-moe/TMP_Typewriter_With_Ruby.git?path=Assets/TMP_Typewriter

    or the classic way with .unitypackage from Releases.
    If you install using .unitypackage, don't forget to install TextMeshPro via Package Manager.

  • Add TMP_Typewriter component to the empty GameObject or that already contain TextMeshPro component.

  • Add TMP_Typewriter namespace to your script and you're ready to go.

    using KoganeUnityLib;

Examples Usage

Normal


m_Typewriter.Play
(
    text        : "ABCDEFG HIJKLMN OPQRSTU",
    speed       : m_TypingSpeed,
    onComplete  : () => Debug.Log("Typing Normal Complete!")
);

Rich Text


m_Typewriter.Play
(
    text        : @"<size=64>ABCDEFG</size> <color=red>HIJKLMN</color> <sprite=0> <link=""https://www.google.com/"">OPQRSTU</link>",
    speed       : m_TypingSpeed,
    onComplete  : () => Debug.Log("Typing Rich Text Complete!")
);

Ruby

You can use <r> or <ruby> tag to wrap the Furigana (small word on top of a word).

m_Typewriter.Play
(
    text        : "このテキストは\n<r=かんじ>漢字</r>テキストに\nルビが<r=ふ>振</r>られます",
    speed       : m_TypingSpeed,
    onComplete  : () => Debug.Log("Typing Ruby (Furigana) Complete!")
);

Sprite


m_Typewriter.Play
(
    text        : @"<sprite=0><sprite=0><sprite=1><sprite=2><sprite=3><sprite=4><sprite=5><sprite=6><sprite=7><sprite=8><sprite=9><sprite=10>",
    speed       : m_TypingSpeed,
    onComplete  : () => Debug.Log("Typing Sprite Complete!")
);

Delay

The delay duration is in seconds.

m_Typewriter.Play
(
    text        : "Hello <delay=2>World!</delay>",
    speed       : m_TypingSpeed,
    onComplete  : () => Debug.Log("Typing Delay Complete!")
);

Pause & Resume


m_Typewriter.Pause();
m_Typewriter.Resume();

Skip


m_Typewriter.Skip(); // with callback (onComplete invoked)
m_Typewriter.Skip(false); // no callback

With CharTweener


License

This project is licensed under MIT License.

Credits

About

A utility to create typing effect for TextMeshPro. Seamlessly support Ruby (Furigana) thanks to RubyTextMeshPro.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • C# 72.4%
  • ShaderLab 24.1%
  • HLSL 3.5%