TMP_Typewriter is a utility to create typing effect for TextMeshPro by utilizing DOTween functionality. Seamlessly support Ruby (Furigana) thanks to RubyTextMeshPro.
- Support Rich Text tags.
- Skippable.
- Can pause and resume.
- Can delay typing effect.
- OnComplete callback.
- Compatible with CharTweener.
-
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;
m_Typewriter.Play
(
text : "ABCDEFG HIJKLMN OPQRSTU",
speed : m_TypingSpeed,
onComplete : () => Debug.Log("Typing Normal Complete!")
);
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!")
);
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!")
);
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!")
);
The delay duration is in seconds.
m_Typewriter.Play
(
text : "Hello <delay=2>World!</delay>",
speed : m_TypingSpeed,
onComplete : () => Debug.Log("Typing Delay Complete!")
);
m_Typewriter.Pause();
m_Typewriter.Resume();
m_Typewriter.Skip(); // with callback (onComplete invoked)
m_Typewriter.Skip(false); // no callback
This project is licensed under MIT License.