Display Changing Variable at Runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Lavitsef
Posts: 5
Joined: Thu Jun 15, 2023 1:13 am

Display Changing Variable at Runtime

Post by Lavitsef »

Hello!

So I want to display a Dialogue System variable in one entry and make it changing randomly from 1 to 100 for each 0.1s, so that for every other 0.1s, a new random number is shown in place of the previous one. I tried to use playmaker to generate random floats and sync it to the variable in Dialogue System, but the dialogue text seems unable to change at runtime. Once the the text shows once, regardless that the playmaker is successfully generating random numbers, the variable shown doesn’t change. So I’m wondering how should I make it work?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: Display Changing Variable at Runtime

Post by Tony Li »

Hi,

Are you referring to the dialogue text shown in a subtitle panel at runtime? If so, then yes - once the panel has shown the text, it doesn't change. You can manually change the text in C# if you need to, such as:

Code: Select all

IEnumerator UpdateText()
{
    int seconds = 0;
    while (true)
    {
        DialogueLua.SetVariable("SecondsWaiting", seconds);
        string updatedText = FormattedText.Parse(DialogueManager.currentConversationState.subtitle.dialogueEntry.subtitleText).text;
        DialogueManager.standardDialogueUI.conversationUIElements.defaultNPCSubtitlePanel.subtitleText = updatedText;
        yield return new WaitForSeconds(1);
        seconds++;
    }
}
(That's just an example to show the concept.)

Note: If you're using this for a timer of some sort, there's probably a better way, such as the response menu's timer functionality.
Lavitsef
Posts: 5
Joined: Thu Jun 15, 2023 1:13 am

Re: Display Changing Variable at Runtime

Post by Lavitsef »

Thanks a lot!! It wasn’t a timer btw :D
Post Reply