Are you sure SaveSystem.BeforeSceneChange() is being called? Are the Increment On Destroy components in the active scene(s) at the time that it's called?
Hi Tony,
Thank you for the quick reply!
* Yes I am absolutely positive that they are called. The code snippet in the Forum post is a direct copy from my source code.
* Yes, my project has only one scene and it basically loads itself again.
I've been stepping through the code BeforeSceneChange() seems to iterate over m_savers.Count
Which includes all the on On Destroy components in the active scene(s) and calling the saver.OnBeforeSceneChange()
Hi Again,
Just to add. It seems to only Trigger the On Destroy component(s) for the objects that were disabled by 'picking them up'
Problem example:
1) Start a new game
2) Pick up a coin.
3) On Destroy objects gets triggered => coin count goes up to 1.
4) Save game in slot 1.
5) Restart Game => Coin count goes to 0 as expected.
6) Load game from slot 1
7) Coin message is shown and coin count goes to 2 (instead of the correct coin count of 1)
Does your scene have a Dialogue System Saver component? It's typically placed on the Dialogue Manager GameObject. Certain Dialogue System components such as Increment On Destroy rely on the Dialogue System Saver to pass them BeforeSceneChange events.
Yes, I placed it on the dialogue manager wiht the standard settings:
Key: empty
Append Saver Type To Key: Not ticked.
Save Accross Scene changes: Ticked
Restore State on Start: Not Ticked
Skip Apply: Ticked
Save Raw Data: Not ticked
When I disable the Dialog System Saver All "On Destroy" items seem to be triggered when loading the slot.
When I enable the Dialog System Saver only the "On Destroy" the items that are disabled due to the loading are triggered.