Resetting persistent dialogue actor's panel number to its initial value

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Resetting persistent dialogue actor's panel number to its initial value

Post by fkkcloud »

Hello,

I implemented a function that resets dialogue actors that I included in the DialgoueManager prefab.
As the DialogueManager prefab is included in the GameManager prefab which is persistent, the dialogue actors that are within the DialogueManager prefab are all persistent now.

I am changing the persistent dialogue actor's panel number manually via code or sequence command, so I need to reset them to their initial value every time I load any new scene.

In GameManager code,

Code: Select all

public DialogueActor[] persistentDialogueActors;
private SubtitlePanelNumber[] _persistentDialogueActorsPanelIDs;

void Awake()
{
        // init persistent Dialogue Actor Panel IDs
        _persistentDialogueActorsPanelIDs = new SubtitlePanelNumber[persistentDialogueActors.Length];
        for (int i = 0; i < persistentDialogueActors.Length; i++)
        {
            _persistentDialogueActorsPanelIDs[i] =
                persistentDialogueActors[i].standardDialogueUISettings.subtitlePanelNumber;
        }
}

public void ResetPersistentDialougeActorPanelNumbers()
    {
        for (int i = 0; i < persistentDialogueActors.Length; i++)
        {
            persistentDialogueActors[i].standardDialogueUISettings.subtitlePanelNumber =
                _persistentDialogueActorsPanelIDs[i];
        }
    }
and I execute that "ResetPersistentDialougeActorPanelNumbers()" function whenever I need to reset (usually when the scene just completed its loading).

Would the above be the ideal way?

Thank you,
J
User avatar
Tony Li
Posts: 21977
Joined: Thu Jul 18, 2013 1:27 pm

Re: Resetting persistent dialogue actor's panel number to its initial value

Post by Tony Li »

Hi,

Yes, that looks good to me.
Post Reply