Page 1 of 1

Need some direction on two issues

Posted: Tue May 28, 2019 5:35 pm
by jnhasty7
Issue #1:
I have Dialogue Managers on two scenes; If I start the two scenes on their own, the dialogue system works, but if I start one scene and move to the second using "LoadLevel()", the second scene dialogue system isn't working.

Issue #2:
I'm changing item variables in one scene, and that's working just fine, but for debugging purposes, I can't figure out how to persist the data to when I start the scene again.
I've tried calling LoadLevel() while I have ticked the "Include All Items & Quest data" under persistent data settings.
I've added these components to the Dialogue Manager:
-Save System
-Dialogue System Saver (with restore state on start ticked).
-Save System Methods
-Player Prefs Saved Game Data Storer
-Auto Save Load (with load on start ticked, and the rest unticked)

but I still can't get the data to persist

Issue#3
Tony, you've helped me before on a few things, and I appreciate your fast responses and diligence. Do you have a patreon or something similar so I can pay respect?

Re: Need some direction on two issues

Posted: Tue May 28, 2019 5:45 pm
by Tony Li
Hi,
jnhasty7 wrote: Tue May 28, 2019 5:35 pmIssue #1:
I have Dialogue Managers on two scenes; If I start the two scenes on their own, the dialogue system works, but if I start one scene and move to the second using "LoadLevel()", the second scene dialogue system isn't working.
This is because the Dialogue Manager GameObject survives scene changes by default. This allows it to keep its variable values and quest states when you change scenes. The Dialogue Manager in the first scene survives into the second scene and replaces the Dialogue Manager in the second scene.

There are two ways to resolve this:

1. Use one Dialogue Manager.
Assign the same dialogue database to all Dialogue Managers in all scenes. If you have more than one database, you can use the Dialogue Editor window's Database > Merge Database feature to merge two databases into one. With this setup, you can playtest from any scene that has a Dialogue Manager. But keep in mind that if you change scenes during play, the Dialogue Manager from the original scene will survive and replace the one in the new scene.

2. Or configure the Dialogue Manager to not survive scene changes.
  • Inspect the Dialogue Managers in all scenes. Untick two checkboxes: Other Settings > Don't Destroy On Load and Allow Only One Instance.
  • Set up the Save System.
  • Continue to use LoadLevel() to change scenes. LoadLevel() is aware of the save system. It will save the variable values before leaving the first scene. It will restore those saved values after entering the second scene.
jnhasty7 wrote: Tue May 28, 2019 5:35 pmIssue #2:
I'm changing item variables in one scene, and that's working just fine, but for debugging purposes, I can't figure out how to persist the data to when I start the scene again.
I've tried calling LoadLevel() while I have ticked the "Include All Items & Quest data" under persistent data settings.
I've added these components to the Dialogue Manager:
-Save System
-Dialogue System Saver (with restore state on start ticked).
-Save System Methods
-Player Prefs Saved Game Data Storer
-Auto Save Load (with load on start ticked, and the rest unticked)
You can probably untick the Dialogue System Saver's Restore State On Start and remove the Auto Save Load unless you really need to auto-save and auto-load when quitting the game and then playing it again later.
jnhasty7 wrote: Tue May 28, 2019 5:35 pmIssue#3
Tony, you've helped me before on a few things, and I appreciate your fast responses and diligence. Do you have a patreon or something similar so I can pay respect?
Reviews on the Asset Store are always very appreciated! :-)

Re: Need some direction on two issues

Posted: Tue May 28, 2019 6:10 pm
by jnhasty7
Thanks Tony.

Issue #1 Fixed

For Issue #2
When changing scenes, the process is the same except the Saved Game Data Storer is not used. The Save System simply holds the save data in memory and applies it to the newly-loaded scene. The Save System performs these steps when changing scenes:
Is there a way I can save to disk during the changing scenes? or is there a way, I can just save at any point by calling a method that's not LoadLevel()?

Also, let's say I'm just starting and stopping a scene with unity, for debugging, and I'm not using "LoadScene()".
So I'm starting a scene, doing actions that change variables/items/quests,
How can I save this data,
Stop the scene using unity,
make some changes or whatever,
start the same scene using unity,
then having the data carry over from when I started the scene previously

Re: Need some direction on two issues

Posted: Tue May 28, 2019 9:10 pm
by Tony Li
For issue #2 / saving to disk:
  • Remove the PlayerPrefs Saved Game Data Storer, and add a Disk Saved Game Data Storer.
  • In a C# script, call PixelCrushers.SaveSystem.SaveToSlot(#), where # is a slot number of your choosing. It can be any number.
  • If you want to hook it up to a UI button instead of writing C# code, add a Save System Methods component to the UI button. Configure the button's OnClick() event to call SaveSystemMethods.SaveToSlot and specify a slot number.
  • Or if you want to use visual scripting such as PlayMaker, there is an equivalent visual scripting action to save the game to a slot.
To load the saved game, in C# use PixelCrushers.SaveSystem.LoadFromSlot(#). Or connect a UI button to SaveSystemMethods.LoadFromSlot. Or use the equivalent visual scripting action.

Re: Need some direction on two issues

Posted: Wed May 29, 2019 9:10 pm
by jnhasty7
SaveToSlot(0) looks like it saved to disk. I have a "save_0.dat" and "saveinfo.dat" in the games AppData.

When I try to LoadFromSlot(0), it says "Save System: LoadFromSlot(0) but there is no saved game in this slot."

Re: Need some direction on two issues

Posted: Wed May 29, 2019 9:15 pm
by Tony Li
Hi,

Are you sure LoadFromSlot(0) is running after SaveToSlot(0) has finished?

Would it be possible for you to send a reproduction project to tony (at) pixelcrushers.com?

Re: Need some direction on two issues

Posted: Mon Jun 03, 2019 9:19 pm
by jnhasty7
Hey Tony, sorry for the late response:

First I start the scene
Image

then I do an action to save

Image

then I notice these files

Image

then I stop the scene

Image

turn on my load script object (this is ran in "void Start()" for my load data game object that is now active)

Image

then I start the scene again

Image

then I get this:

Image

maybe I'm calling Load too early?

Re: Need some direction on two issues

Posted: Mon Jun 03, 2019 9:33 pm
by Tony Li
Another user recently reported the same issue: HasSavedGameInSlot only works half the time.

Their solution was to use a coroutine to wait until the end of frame.

I posted an explanation of the issue here.

Version 2.1.7 should update the DiskSavedGameDataStorer so it no longer has this issue.

Re: Need some direction on two issues

Posted: Mon Jun 03, 2019 9:40 pm
by Tony Li
(Version 2.1.7 is scheduled for release this Friday, barring any unforeseen issues.)