Hi Tony,
In my game, I would like certain UI to appear when the dollar amount in the conversation is displayed. For example in the following sentence, "The purchase price was $100,000 (show UI on the screen for this $100,000) not a penny more, not a penny less." Is there a way to send an event off when a certain word in a sentence is displayed (like the $100,000 in the example above)?
Right now, I only know how to use the add scene event on that line of dialogue, but then the UI appears a little too early since it shows it at the beginning of the sentence before the dramatic reveal of the price mid-sentence.
Hopefully, that all makes sense. Thanks again!
Trigger an event on a single word in a dialogue conversation
Re: Trigger an event on a single word in a dialogue conversation
Hi,
The easiest way is to figure out how long you need to wait before showing the UI. Then use the Sequence field to show it at that time. For example, if it will take 1.5 seconds to get to that point in the typewriter, set the Sequence field to something like:
The {{default}} tells the dialogue entry node to also play the regular default sequence in addition to activating the GameObject named DollarsUI at the 1.5 second mark.
If you don't want to do that for some reason, here are some scripting options:
1. You can make a subclass of the typewriter effect (e.g., UnityUITypewriterEffect) and override some methods to extract a new token that you'd define. When the typewriter gets to that token, perform your action (e.g., show UI on screen).
2. This one might be simpler to implement than #1: Or you can write a short script with an OnConversationLine method. Define a string to recognize (e.g., "[showUI]"). In OnConversationLine, extract that tag, and identify the string that precedes it. Then set a timer to show the UI after the time it will take to type the preceding string. Call ConversationView.GetDefaultSubtitleDuration(string) to determine the time to wait.
The easiest way is to figure out how long you need to wait before showing the UI. Then use the Sequence field to show it at that time. For example, if it will take 1.5 seconds to get to that point in the typewriter, set the Sequence field to something like:
Code: Select all
{{default}}
SetActive(DollarsUI,true)@1.5
If you don't want to do that for some reason, here are some scripting options:
1. You can make a subclass of the typewriter effect (e.g., UnityUITypewriterEffect) and override some methods to extract a new token that you'd define. When the typewriter gets to that token, perform your action (e.g., show UI on screen).
2. This one might be simpler to implement than #1: Or you can write a short script with an OnConversationLine method. Define a string to recognize (e.g., "[showUI]"). In OnConversationLine, extract that tag, and identify the string that precedes it. Then set a timer to show the UI after the time it will take to type the preceding string. Call ConversationView.GetDefaultSubtitleDuration(string) to determine the time to wait.
Re: Trigger an event on a single word in a dialogue conversation
Thanks Tony. I think I got it figured out for now. If I get stuck I'll let you know. Appreciate your quick response as usual!