SaveSystem causing Awake() to be called multiple times
Posted: Sat Dec 12, 2020 5:15 pm
Hi Tony,
I've run into a little issue that I think has probably been occuring for a while and just hasn't affected anything strangely until now. I'm using the PixelCrushers save system to save and load, and it appears to result in the Awake() method being called multiple times.
If I start from fresh (no save files), Awake() is called once. If I play the game in the editor, then quit, then play again, Awake is called 3 times, once before the save system loads, and twice after. Included is a screenshot of the console and here is just some super simple code I'm using in one of my classes:
https://ibb.co/jMZpKKf
Any idea what could be causing this? There are no duplicates of this specific class, and the savesystem is on just one gameobject in the scene. In this specific case, there was no change in scene from the editor to play mode.
I've run into a little issue that I think has probably been occuring for a while and just hasn't affected anything strangely until now. I'm using the PixelCrushers save system to save and load, and it appears to result in the Awake() method being called multiple times.
If I start from fresh (no save files), Awake() is called once. If I play the game in the editor, then quit, then play again, Awake is called 3 times, once before the save system loads, and twice after. Included is a screenshot of the console and here is just some super simple code I'm using in one of my classes:
Code: Select all
private void Awake()
{
Debug.Log("Calling awake");
SaveSystem.saveDataApplied += OnSaveDataApplied;
EventHandler.ScenePortalTriggered += SaveBeforeChangingScenes;
}
void OnSaveDataApplied()
{
Debug.Log("save data applied");
}
Any idea what could be causing this? There are no duplicates of this specific class, and the savesystem is on just one gameobject in the scene. In this specific case, there was no change in scene from the editor to play mode.