BeforeSceneChange and LoadFromSlot problems

Announcements, support questions, and discussion for the Dialogue System.
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

Hi Pixel Crushers,
I love your system so far. I have however one issue with the following code (snippet)

Code: Select all

            
            SaveSystem.BeforeSceneChange();
            SaveSystem.LoadFromSlot(selectedSlot);
It loads the scene correctly. But the objects that have an IncrementOnDestroy attached still trigger.

Please help. It has been driving me up the wall!
Thank you very much in advance
User avatar
Tony Li
Posts: 22047
Joined: Thu Jul 18, 2013 1:27 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by Tony Li »

Hi,

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?
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

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()
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

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)
User avatar
Tony Li
Posts: 22047
Joined: Thu Jul 18, 2013 1:27 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by Tony Li »

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.
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

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
User avatar
Tony Li
Posts: 22047
Joined: Thu Jul 18, 2013 1:27 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by Tony Li »

Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

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.
putte954
Posts: 8
Joined: Thu Mar 18, 2021 12:28 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by putte954 »

The problem is, it's 2.6Giga bytes big..
I'm a bit of a Unity Noob so I don't know how to boil that down to only the files you need?
User avatar
Tony Li
Posts: 22047
Joined: Thu Jul 18, 2013 1:27 pm

Re: BeforeSceneChange and LoadFromSlot problems

Post by Tony Li »

It's fine to send a 2.6 GB project. The reproduction project link above explains which files you can zip up and which you can omit.

I can try to reproduce it here later today first if you'd prefer.
Post Reply