Page 1 of 1

Display Changing Variable at Runtime

Posted: Thu Jun 15, 2023 1:24 am
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?

Re: Display Changing Variable at Runtime

Posted: Thu Jun 15, 2023 9:16 am
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.

Re: Display Changing Variable at Runtime

Posted: Thu Jun 15, 2023 9:38 am
by Lavitsef
Thanks a lot!! It wasn’t a timer btw :D