Hi Tony,
I am currently experiencing some issues with variables not being refreshed upon a load game. I am currently using this guide to save and load my quest and dialogue states: https://www.pixelcrushers.com/phpbb/vie ... php?t=2796. I am confident the save/load functionality in the linked post above works, as I can successfully save / load quest states from quest machine. I just have issues with Dialogue System's variables that does not get properly loaded.
I have recently adopted the use of Dialogue System variables, mainly used to prevent the repetition of specific dialogue text. I would set variable["TalkedToGuard'] = true after talking to a guard, and set the conversation condition to variable["TalkedToGuard'] == false.
Let's say I save the game prior to talking to the guards, so variable["TalkedToGuard'] == false. However, after I spoke to the guards and load game via my in-game load UI button that uses the lines of code from the link above, the variables does not get loaded back to my previous save state (I.e. variable["TalkedToGuard'] is still true). Interestingly, I noticed that I can stop and start the game view via the Unity Editor's Play button, and using the exact same load functionality as with the in-game load UI button, the variables does get refreshed.
In summary, I have issues with having my variables refreshed using the in-game load UI button. A workaround would be to use Unity Editor's Play button to reload the game, which calls the exact same load functionality. I wonder if some of these variables are cached internally, and are only un-cached upon Unity's play button?
Thanks as always,
Derek
Variable does not refresh on Game Load
Re: Variable does not refresh on Game Load
Hi Derek,
Does your Dialogue Manager GameObject have a Dialogue System Saver component? Technically this component can be anywhere -- for example, it can be on the Save System GameObject if that's a separate GameObject. But I usually put it on the Dialogue Manager since that seems the most logical to me.
Wherever it is, assign a unique Key value to it. Otherwise, if another Saver component on the same GameObject also doesn't have a Key value set, they could be overwriting each others' data.
Also make sure it's Save Across Scene Changes checkbox is ticked.
If that doesn't help, then to debug it further you can temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log a lot of info to the Console window. You can trace through it to get an idea of what's going on under the hood.
Does your Dialogue Manager GameObject have a Dialogue System Saver component? Technically this component can be anywhere -- for example, it can be on the Save System GameObject if that's a separate GameObject. But I usually put it on the Dialogue Manager since that seems the most logical to me.
Wherever it is, assign a unique Key value to it. Otherwise, if another Saver component on the same GameObject also doesn't have a Key value set, they could be overwriting each others' data.
Also make sure it's Save Across Scene Changes checkbox is ticked.
If that doesn't help, then to debug it further you can temporarily set the Dialogue Manager's Other Settings > Debug Level to Info. This will log a lot of info to the Console window. You can trace through it to get an idea of what's going on under the hood.
-
- Posts: 16
- Joined: Wed Sep 29, 2021 1:51 pm
Re: Variable does not refresh on Game Load
Hi Tony,
Thanks for your reply. I do have a Dialogue System Saver component in my dialogue manager. However, this dialogue manager of mine is actually made to be a prefab that is used across all scenes (therefore, all of it has the same name). If so, do I need to assign different keys to the Dialogue System Saver component in the different scenes?
I am using this Dialogue System Database Setup from my previous post (first option). For now, all variables are local to the database / scene, and hence saving only needs to happen locally. If so, I assume that all scenes need to have different save keys?
Conversely, if I hope to have variables that are saved and persist across scenes, I will need to place all key variables in the "Initial Database", and save that with a separate key?
Thanks for your reply. I do have a Dialogue System Saver component in my dialogue manager. However, this dialogue manager of mine is actually made to be a prefab that is used across all scenes (therefore, all of it has the same name). If so, do I need to assign different keys to the Dialogue System Saver component in the different scenes?
I am using this Dialogue System Database Setup from my previous post (first option). For now, all variables are local to the database / scene, and hence saving only needs to happen locally. If so, I assume that all scenes need to have different save keys?
Conversely, if I hope to have variables that are saved and persist across scenes, I will need to place all key variables in the "Initial Database", and save that with a separate key?
Re: Variable does not refresh on Game Load
Hi,
The Dialogue System Savers in all scenes should have the same key value. So set it once in the prefab and leave it unchanged in all instances in all scenes.
If you want variables to persist, put them in the Dialogue Manager's Initial Database or in databases that get loaded at start and stay loaded for the duration of the game.
The Dialogue System Savers in all scenes should have the same key value. So set it once in the prefab and leave it unchanged in all instances in all scenes.
If you want variables to persist, put them in the Dialogue Manager's Initial Database or in databases that get loaded at start and stay loaded for the duration of the game.