Continue Button Animation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
BaddyDan
Posts: 14
Joined: Tue May 05, 2015 2:52 pm

Continue Button Animation

Post by BaddyDan »

Hello,



I am trying to play a little animated icon, and have it only show at the end of a text segment. So far, it is visible, but it displays throughout the dialogue typing. Is there a way to make it visible only after the typewriter effect has finished? Thanks in advance!
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Continue Button Animation

Post by Tony Li »

Hi,



The easiest way is to show the icon after a specified duration. For example, set your Sequence to:

SetActive(MyIcon)@2; required SetActive(MyIcon,false)@{{end}}

This example assumes you're showing the icon by activating a GameObject "MyIcon". At the 2-second mark, it activates MyIcon. At the end value (determined by the length of the dialogue text), it deactivates MyIcon. The "required" keyword ensures that it always deactivates MyIcon even if the player skips ahead.







To show the icon exactly when the typewriter effect ends, use these two steps: First, set the Sequence to:

SetActive(MyIcon)@Message(TypewriterDone); required SetActive(MyIcon,false)@{{end}}

This doesn't activate MyIcon until the sequencer receives a message "TypewriterDone".







Next, duplicate the typewriter effect script. If you're using Unity UI, copy UnityUITypewriterEffect.cs and call it, say, CustomUnityUITypewriterEffect. Make these two changes in the script:







1. Change the class name to match the filename:

public class CustomUnityUITypewriterEffect : MonoBehaviour {...





2. At the end of the effect coroutine, add this line:

Sequencer.Message("TypewriterDone");





Finally, assign this script to your subtitle line instead of the original typewriter script (e.g., UnityUITypewriterEffect).


BaddyDan
Posts: 14
Joined: Tue May 05, 2015 2:52 pm

Continue Button Animation

Post by BaddyDan »

Sir, you are amazing. Thank you!
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Continue Button Animation

Post by Tony Li »

Pleasure to help!
chrislow19
Posts: 34
Joined: Mon Dec 30, 2019 4:26 pm

Re: Continue Button Animation

Post by chrislow19 »

Hi Tony, would it be the same idea for the Textmeshpro typewriter effect?
User avatar
Tony Li
Posts: 22102
Joined: Thu Jul 18, 2013 1:27 pm

Re: Continue Button Animation

Post by Tony Li »

Yes, it should use the same basic steps.
Post Reply