Page 3 of 4
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 11:50 am
by Tony Li
What are the settings on the Dialogue System Saver component?
Since you're using Auto Save Load with Load On Start ticked, you may need to delay the Dialogue System Trigger for one or more frames. Here's a test:
1. Change the Dialogue System Trigger to OnUse.
2. Add a TimedEvent component to the same GameObject. Set the dropdown to Frames. Set the value to 2. Configure the OnTimeReached() event to call the Dialogue System Trigger's DialogueSystemTrigger.OnUse method.
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 12:14 pm
by soniclinkerman
Here are my settings
- Settings.png (49.69 KiB) Viewed 536 times
2. Add a TimedEvent component to the same GameObject. Set the dropdown to Frames. Set the value to 2. Configure the OnTimeReached() event to call the Dialogue System Trigger's DialogueSystemTrigger.OnUse method.
I just replaced my "Start" conversation and made it use "OnUse" as you mentioned. So far, this seems to work except for the last level dialogue at the start of the game. Should I increase the amount of frames it takes?
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 12:22 pm
by Tony Li
Hi,
Yes, that's correct. Since both Auto Save Load and the Dialogue System Trigger do their thing in Start, the trigger was going first. You can keep it set up the way it is now, or you can go into Script Execution Order and set Auto Save Load to run first.
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 12:39 pm
by soniclinkerman
Gotcha. Ok I just went through the whole game and it looks like it works as intended!
You mentioned how to restart dialogue earlier using onclick, but I was curious if there was a way where it would restart on runtime WITHOUT having to load to the next scene right away?
I pretty much just want it to reset on the "Menu" scene without having to reload
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 1:44 pm
by Tony Li
Hi,
To reset the data without loading a scene, call
PixelCrushers.SaveSystem.ResetGameState().
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 2:34 pm
by soniclinkerman
I just placed this in my script as shown
Code: Select all
if (Input.GetKeyDown(KeyCode.R) && canResetData)
{
PixelCrushers.SaveSystem.ResetGameState();
Debug.Log("RESET");
}
The console.log runs, but the game hasn't reset. Am I doing this wrong?
I put this on the top of my script
Code: Select all
using PixelCrushers.DialogueSystem;
It shows re squiggles, but I assume that's just because Visual Studio doesn't recognize this
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 2:44 pm
by Tony Li
By "reset," I assume you want to clear all save data from memory and reset all Dialogue System variables to their initial values, correct? If so, that should do it. Make sure the scene has a Dialogue System Saver component at the time that you run SaveSystem.ResetGameState().
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 3:02 pm
by soniclinkerman
Ok so my "Save System" GameObject has the script "Dialogue System Saver".
So what supposed to happens is: when I press the Z button, the game should just reset it's dialogue variables
Code: Select all
if (Input.GetKeyDown(KeyCode.Z))
{
audioSource.PlayOneShot(selected);
PixelCrushers.SaveSystem.ResetGameState();
Debug.Log("RESET");
}
But for some reason, this isn't actually producing those results. It always prints out "reset", but when I push the button that's meant to start the game, the retrieved data doesn't set the variables that are meant to go back to normal. They're still values from the "saved" version
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 3:07 pm
by Tony Li
Thanks for the explanation. The problem is that you're resetting the variable values in memory, but then you're loading the old saved variable values from the saved game back into memory. If you use SaveSystem.ResetGameState(), don't undo that by reloading your saved game.
If you want to reset the game state
and clear out the saved game, also call
SaveSystem.DeleteSavedGameInSlot():
Code: Select all
PixelCrushers.SaveSystem.ResetGameState();
PixelCrushers.SaveSystem.DeleteSavedGameInSlot(1);
Re: Save dialogue settings when closing application
Posted: Sun Apr 18, 2021 3:20 pm
by soniclinkerman
That was it! Now it works as intended!
I can't think you enough for your help and guiding me through this. I really appreciate it. I'm about to leave a 5 start review right now for this product and amazing service !