SaveSystem.loadEnded is not invoking
Posted: Sun Jul 02, 2023 6:54 am
Hey!
I have a simple class that sends the UnityEvent onGameLoadNDataApplied; to all initializators when the game has loaded + savedataapplied. However, after a few tests, I noticed that this event doesn't work, and I saw through the console that there was a problem with loadEnded.
I didn't change the source code (except that I made my own TransitionManager:SceneTransitionManager, and also added a bool to the Selector component to keep track of the state).
By the way I think this class used to work, but to be honest I never tested it until today
UPD
In case somebody has same problem, you need to find public static void LoadFromSlot(int slotNumber) SaveSystem.cs method and delete if (loadStarted.GetInvocationList().Length > 1) check, and (as i understand) also delete else{ LoadFromSlotNow(slotNumber);}
I have a simple class that sends the UnityEvent onGameLoadNDataApplied; to all initializators when the game has loaded + savedataapplied. However, after a few tests, I noticed that this event doesn't work, and I saw through the console that there was a problem with loadEnded.
Code: Select all
[SerializeField] private UnityEvent onGameLoadNDataApplied;
private bool loadedSavedGame; //Is game loaded?
private void Start()
{
SaveSystem.loadEnded += () => Debug.Log("Savesystem LoadEnded");
SaveSystem.loadEnded += OnLoadEnded;
SaveSystem.saveDataApplied += () => Debug.Log("Savesystem DataApplied");
SaveSystem.saveDataApplied += OnSaveDataApplied;
Debug.Log("Subscribed to SaveSystem events");
}
private void OnLoadEnded()
{
Debug.Log("Game loaded");
SaveSystem.loadEnded -= OnLoadEnded;
loadedSavedGame = true;
}
private void OnSaveDataApplied()
{
if(loadedSavedGame)
{
SaveSystem.saveDataApplied -= OnSaveDataApplied;
Debug.Log("Save data applied");
onGameLoadNDataApplied.Invoke();
}
}
By the way I think this class used to work, but to be honest I never tested it until today
UPD
In case somebody has same problem, you need to find public static void LoadFromSlot(int slotNumber) SaveSystem.cs method and delete if (loadStarted.GetInvocationList().Length > 1) check, and (as i understand) also delete else{ LoadFromSlotNow(slotNumber);}