Page 1 of 1

Possible to fade in the letters with a Typewriter?

Posted: Sat Mar 20, 2021 10:48 pm
by Jamez0r
Hey Tony and everyone :D

I'm experimenting with the typewriter effect, but I feel like it would fit our games' style a bit more if the letters faded in instead of appearing instantly. I didn't see anything out-of-the-box to have the letters fade in, so I started googling and found this: https://forum.unity.com/threads/have-wo ... st-6301222

I tested out that code snippet (I'm using TMPro) and it looked to work pretty well! So I'm wondering if I could combine their fade-in technique with the Typewriter.

My goal would be:
-Have text appear in the Typewriter fashion, but to fade in the characters instead of having them instantly appear.
-Keep the ability to use all of the parsing that the Typewriter can do (namely RPGMakerCodes for pauses/timing).
-Still be able to press the Continue button to "skip to the end" (aka instantly show the entire text) like how the Typewriter does it.

I don't have the most experience with doing custom stuff with TMPro, but this is what I see from looking at the Typewriter code and this TMPro-Fade code: The Typewriter uses 'maxVisibleCharacters' to have the characters appear. The TMPro-Fade code looks to be setting the vertex colors for each of the characters - controlling their Alpha so they fade in.

I feel like I should be able to take the Typewriter code as the starting point, and only change the necessary parts so that the characters are revealed using the TMPro-Fade method.
Any opinion on this being a good idea or not? :lol:

Thanks for any help!

Re: Possible to fade in the letters with a Typewriter?

Posted: Sat Mar 20, 2021 10:53 pm
by Tony Li
Hi,

That sounds fine. I recommend making a subclass of TextMeshProTypewriterEffect and overriding the Play() coroutine. (It's virtual for reasons like this.)

Re: Possible to fade in the letters with a Typewriter?

Posted: Mon Mar 22, 2021 10:19 am
by Jamez0r
Thanks Tony, good call on the subclass - I'll give it a shot!