Alerts on loadFromSlot
Alerts on loadFromSlot
Hi all, the issue that im having is that when i use the LoadFromSlot method, from saveSystemMethods, after loading a new scene, the alert messages that occurred in my previous saved session, suddenly pop up.
I've done my research in the forum, and the solution that tony suggests and as far as i had understand it, is pretty much call PersistentDataManager.LevelWillBeUnloaded() whenever im going to do a load scene, this to avoid the IncrementOnDestroy to being called when the OnDestroy on the gameobjects that have the component is performed. This is not working for me, reason why i would like to get some insight on what my issue may be.
Some background of my project architecture is pretty much a login, characterselect, GameWorld.
When i load the GameWorld scene, i call the LoadFromSlot in a component Start(), and right away i get the alert pop ups.
I've done my research in the forum, and the solution that tony suggests and as far as i had understand it, is pretty much call PersistentDataManager.LevelWillBeUnloaded() whenever im going to do a load scene, this to avoid the IncrementOnDestroy to being called when the OnDestroy on the gameobjects that have the component is performed. This is not working for me, reason why i would like to get some insight on what my issue may be.
Some background of my project architecture is pretty much a login, characterselect, GameWorld.
When i load the GameWorld scene, i call the LoadFromSlot in a component Start(), and right away i get the alert pop ups.
Re: Alerts on loadFromSlot
Hi,
Where do the alerts come from? Do they come from Increment On Destroy components?
PersistentDataManager.LevelWillBeUnloaded() has been superceded by SaveSystem.BeforeSceneChange().
However, you don't need to call SaveSystem.BeforeSceneChange() if you use SaveSystemMethods.LoadFromSlot(). This is because SaveSystemMethods.LoadFromSlot() will automatically call SaveSystem.BeforeSceneChange() for you.
Where do the alerts come from? Do they come from Increment On Destroy components?
PersistentDataManager.LevelWillBeUnloaded() has been superceded by SaveSystem.BeforeSceneChange().
However, you don't need to call SaveSystem.BeforeSceneChange() if you use SaveSystemMethods.LoadFromSlot(). This is because SaveSystemMethods.LoadFromSlot() will automatically call SaveSystem.BeforeSceneChange() for you.
Re: Alerts on loadFromSlot
Indeed, the alerts come from an Increment On Destroy component.
The thing is that im using SaveSystemMethods.LoadFromSlot(), AFTER i do the loadScene(Which i do myself, not using the Dialogue Sytem load scene methods) which is done in an Start() method of a component.
In the meantime i used SaveSystem.BeforeSceneChange(), before calling my scene load in my login, but the issue persists.
The thing is that im using SaveSystemMethods.LoadFromSlot(), AFTER i do the loadScene(Which i do myself, not using the Dialogue Sytem load scene methods) which is done in an Start() method of a component.
In the meantime i used SaveSystem.BeforeSceneChange(), before calling my scene load in my login, but the issue persists.
Re: Alerts on loadFromSlot
Hi,
If you call SaveSystem.BeforeSceneChange() before calling your own SceneManager.LoadScene(), then the Increment On Destroy components shouldn't trigger, and they shouldn't show alerts.
Can you use SaveSystem.LoadScene() instead of your own LoadScene()?
If not, then are you sure SaveSystem.BeforeSceneChange() is being called while in the scene containing the Increment On Destroy components?
If you call SaveSystem.BeforeSceneChange() before calling your own SceneManager.LoadScene(), then the Increment On Destroy components shouldn't trigger, and they shouldn't show alerts.
Can you use SaveSystem.LoadScene() instead of your own LoadScene()?
If not, then are you sure SaveSystem.BeforeSceneChange() is being called while in the scene containing the Increment On Destroy components?
Re: Alerts on loadFromSlot
Alright, i was calling SaveSystem.BeforeSceneChange() in a component located in my login scene(which does not have Dialogue Manager prefab) right before doing SceneManager.LoadScene(). Now im calling SaveSystem.BeforeSceneChange() right before calling the LoadFromSlot() in my ingame scene, and it does remove the alerts pop up right after the load, now the thing is that it won't let new alerts pop up since i suppose the SaveSystem is waiting for a new scene to load, which makes me think that in order for the SaveSystem.BeforeSceneChange() to work, the Dialogue Manager must be present in the scene which makes the load.
is there any workaround for me to not have the Dialogue Manager prefab in my login scene?
is there any workaround for me to not have the Dialogue Manager prefab in my login scene?
Re: Alerts on loadFromSlot
Yes. In that case call PersistentDataManager.LevelWillBeUnloaded(). This bypasses the Dialogue Manager.
When you use SaveSystem.BeforeSceneChange(), it makes the following calls:
However, be aware that if you use the DestructibleSaver component in your scene, it listens directly for SaveSystem.BeforeSceneChange(), so it won't know that the GameObject is being destroyed by a level change unless you call SaveSystem.BeforeSceneChange.
When you use SaveSystem.BeforeSceneChange(), it makes the following calls:
- SaveSystem.BeforeSceneChange()
- --> calls DialogueSystemSaver.BeforeSceneChange() (assumes Dialogue Manager w/DialogueSystemSaver is present)
- --> calls PersistentDataManager.LevelWillBeUnloaded()
- --> calls IncrementOnDestroy,OnLevelWillBeUnloaded()
However, be aware that if you use the DestructibleSaver component in your scene, it listens directly for SaveSystem.BeforeSceneChange(), so it won't know that the GameObject is being destroyed by a level change unless you call SaveSystem.BeforeSceneChange.
Re: Alerts on loadFromSlot
I tried calling LevelWillBeUnloaded() before my scene load, which looks like this:
IEnumerator LoadingGame()
{
PixelCrushers.DialogueSystem.PersistentDataManager.LevelWillBeUnloaded();
asyncLoadLevel = SceneManager.LoadSceneAsync("Ingame", LoadSceneMode.Additive);
yield return new WaitUntil(() => asyncLoadLevel.isDone==true);
SceneManager.UnloadSceneAsync("Login");
}
It did not work, im still getting the pop ups alerts on load. Im not sure if it's because in a certain moment both scenes are still active since it's additive, so it really never changes to a new scene?
And regarding the DestructibleSaver issue, the recommended way to fix this up is definately have the DialogueManager prefab present in the login scene, and therefore using the SaveSystem.LoadScene() for it to work correctly?
IEnumerator LoadingGame()
{
PixelCrushers.DialogueSystem.PersistentDataManager.LevelWillBeUnloaded();
asyncLoadLevel = SceneManager.LoadSceneAsync("Ingame", LoadSceneMode.Additive);
yield return new WaitUntil(() => asyncLoadLevel.isDone==true);
SceneManager.UnloadSceneAsync("Login");
}
It did not work, im still getting the pop ups alerts on load. Im not sure if it's because in a certain moment both scenes are still active since it's additive, so it really never changes to a new scene?
And regarding the DestructibleSaver issue, the recommended way to fix this up is definately have the DialogueManager prefab present in the login scene, and therefore using the SaveSystem.LoadScene() for it to work correctly?
Re: Alerts on loadFromSlot
Which scene contains the IncrementOnDestroy components? ingame or Login?
Re: Alerts on loadFromSlot
Hi,
If you're using DestructibleSaver, then yes, you should probably have the Dialogue Manager in your login scene (or whatever your first scene is).
IncrementOnDestroy doesn't really care about scene loading/unloading. It just reacts to OnDestroy/OnDisable. If you unload the IncrementOnDestroy's scene, Unity will call IncrementOnDestroy's OnDisable and OnDestroy methods, which will increment the DS variable and show the alert -- unless you have previously called BeforeSceneChange/LevelWillBeUnloaded.
If you're using DestructibleSaver, then yes, you should probably have the Dialogue Manager in your login scene (or whatever your first scene is).
IncrementOnDestroy doesn't really care about scene loading/unloading. It just reacts to OnDestroy/OnDisable. If you unload the IncrementOnDestroy's scene, Unity will call IncrementOnDestroy's OnDisable and OnDestroy methods, which will increment the DS variable and show the alert -- unless you have previously called BeforeSceneChange/LevelWillBeUnloaded.