Page 1 of 1

When quests, variables are loaded.

Posted: Tue Mar 09, 2021 4:41 pm
by Espes
Hello. I want to initialize stuff on scene load, by checking quest, variables states. When to check these? In Awake, Start or there is an event that I can subscribe to e.g OnQuestLoad?

Re: When quests, variables are loaded.

Posted: Tue Mar 09, 2021 5:17 pm
by Tony Li
Hi,

If you want to know when the Dialogue Manager has loaded the dialogue database into memory and prepared the Lua environment, hook into DialogueManager.instance.initializationComplete:

Code: Select all

void Awake()
{
    DialogueManager.instance.initializationComplete += OnDialogueSystemReady;
}

void OnDialogueSystemReady()
{
    DialogueManager.instance.initializationComplete -= OnDialogueSystemReady;
    // (Do your thing here.)
}
If you want to know when the save system has finished loading a scene and applying saved game data, hook into SaveSystem.saveDataApplied:

Code: Select all

void Awake()
{
    // Save system may take more than one frame after scene starts to apply save data.
    // (You can configure the number of frames on the Save System GameObject.)
    SaveSystem.saveDataApplied += OnSavedDataApplied;
}

void OnSaveDataApplied()
{
    SaveSystem.saveDataApplied += OnSavedDataApplied;
    // (Do your thing here.)
}

Re: When quests, variables are loaded.

Posted: Tue Mar 09, 2021 5:41 pm
by Espes
Great! Thank you!

Re: When quests, variables are loaded.

Posted: Tue Mar 09, 2021 8:02 pm
by Tony Li
Happy to help!