Trouble with saving
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Trouble with saving
I have a little bit of a complicated setup, and I'm having trouble getting saving to work for Quest Machine (or the Dialogue System). I followed the instructions to the best of my ability, but I'm sure I messed up something.
I am using Dialogue System, Quest Machine, and Ultimate Inventory System. I'm attempting to tie UIS into the Pixel Crushers Save System, and so far it saves everything from UIS just fine. However, my dialogue system and quest machine data is not saving when I exit play mode and restart or if I change scenes.
I've attached images of my setup, so hopefully you can help me figure it out.
Also, I'm getting an odd console error from the Dialog System which I've attached as well.
https://ibb.co/YZnSGT2
https://ibb.co/89YDc1X
https://ibb.co/3y9rn6p
https://ibb.co/NtqtRs2
Thanks for the great support so far!
I am using Dialogue System, Quest Machine, and Ultimate Inventory System. I'm attempting to tie UIS into the Pixel Crushers Save System, and so far it saves everything from UIS just fine. However, my dialogue system and quest machine data is not saving when I exit play mode and restart or if I change scenes.
I've attached images of my setup, so hopefully you can help me figure it out.
Also, I'm getting an odd console error from the Dialog System which I've attached as well.
https://ibb.co/YZnSGT2
https://ibb.co/89YDc1X
https://ibb.co/3y9rn6p
https://ibb.co/NtqtRs2
Thanks for the great support so far!
Re: Trouble with saving
Hi,
A few little adjustments might to the trick:
- On the Game GameObject, remove the Save System Manager component entirely; don't just disable it.
- On the Dialogue Manager GameObject, assign unique Key values to Dialogue System Saver and UIS Saver. Since their Key fields are blank, they'll end up overwriting each other's save data using the same default key value, which is the GameObject name.
A few little adjustments might to the trick:
- On the Game GameObject, remove the Save System Manager component entirely; don't just disable it.
- On the Dialogue Manager GameObject, assign unique Key values to Dialogue System Saver and UIS Saver. Since their Key fields are blank, they'll end up overwriting each other's save data using the same default key value, which is the GameObject name.
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Trouble with saving
Well, that did something... . The Dialogue System LUA error is gone.
But now UIS isn't saving at all, and Dialogue System and Quest Machine data isn't saving still (either on exit playmode or scene change).
What am I missing?
But now UIS isn't saving at all, and Dialogue System and Quest Machine data isn't saving still (either on exit playmode or scene change).
What am I missing?
Re: Trouble with saving
Hi,
Are there any warnings or errors in the Console?
Please review the steps in Ultimate Inventory System Support.
Does the Dialogue System UIS integration's example scene save and load correctly in your project?
Are there any warnings or errors in the Console?
Please review the steps in Ultimate Inventory System Support.
Does the Dialogue System UIS integration's example scene save and load correctly in your project?
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Trouble with saving
No errors or warnings in the console, sadly. I went back through the UIS Support instructions, and I had everything set up correctly, but still nothing is saving.
Hoping to give you some more info, I've tried several things to get more data:
- Brand new Unity project, UIS + Quest Machine Demo scene. Hit play, pick up heal weed x2, check inventory for heal weed, exit play mode. Hit play, no heal weed in inventory. I fiddled around with all of the settings for auto load on start/save on quit, etc. and nothing changed this behavior. Manual Save/Load works while in Play mode (heal weed stays in inventory). Note, it appears the demo uses the UIS save system. However, when I exit playmode, hit play, and load game, the heal weed is not in the inventory. Same with the QM info - it saves the state if I manually save/load while in playmode, but when I exit playmode, play, load, it defaults back to the initial state.
- Brand new Unity project, UIS + Dialogue System Demo. Same as before, heal weed isn't in inventory. I added an Auto Save Load component to the Pixel Crushers Save System and that didn't have any effect. I tried manually saving in the inventory menu (Save/Load DS) and that seemed to work when I loaded my save. But I can't seem to get any sort of auto saving to work.
- On my own unity game build, set everything up as it's setup in the new Unity project with UIS + DS Demo. Saving and loading works with the Pixelcrushers saver, but *only* while I'm in play mode. It also appears that DS and QM data is reloading correctly as well. However, if I exit play mode and load the game, my inventory is blank again and the DS and GM is set back to its initial state. I have Debug on, and it says it's saving and loading with no errors. When I add back the Inventory Saver component (and tick don't destroy on load) in my working game build, UIS saves fine, but none of the Dialogue System or Quest Machine stuff saves.
Note - all unity projects are on 2020.1.3f1
Hopefully that all provides some info and I spelled it out clearly. I'm happy to provide more information, as I'd love to get this all working. My goal is to have everything save automatically without having to manually save, but I'll take baby steps.
Really appreciate all the help.
Hoping to give you some more info, I've tried several things to get more data:
- Brand new Unity project, UIS + Quest Machine Demo scene. Hit play, pick up heal weed x2, check inventory for heal weed, exit play mode. Hit play, no heal weed in inventory. I fiddled around with all of the settings for auto load on start/save on quit, etc. and nothing changed this behavior. Manual Save/Load works while in Play mode (heal weed stays in inventory). Note, it appears the demo uses the UIS save system. However, when I exit playmode, hit play, and load game, the heal weed is not in the inventory. Same with the QM info - it saves the state if I manually save/load while in playmode, but when I exit playmode, play, load, it defaults back to the initial state.
- Brand new Unity project, UIS + Dialogue System Demo. Same as before, heal weed isn't in inventory. I added an Auto Save Load component to the Pixel Crushers Save System and that didn't have any effect. I tried manually saving in the inventory menu (Save/Load DS) and that seemed to work when I loaded my save. But I can't seem to get any sort of auto saving to work.
- On my own unity game build, set everything up as it's setup in the new Unity project with UIS + DS Demo. Saving and loading works with the Pixelcrushers saver, but *only* while I'm in play mode. It also appears that DS and QM data is reloading correctly as well. However, if I exit play mode and load the game, my inventory is blank again and the DS and GM is set back to its initial state. I have Debug on, and it says it's saving and loading with no errors. When I add back the Inventory Saver component (and tick don't destroy on load) in my working game build, UIS saves fine, but none of the Dialogue System or Quest Machine stuff saves.
Note - all unity projects are on 2020.1.3f1
Hopefully that all provides some info and I spelled it out clearly. I'm happy to provide more information, as I'd love to get this all working. My goal is to have everything save automatically without having to manually save, but I'll take baby steps.
Really appreciate all the help.
Re: Trouble with saving
Hi,
Thanks for the detailed info.
The integration's demos tie into the original UIS demo's menu UI, but you'll notice that the save/load buttons aren't quite as pretty. This is because they use a simple save/load test script to save and load using the Pixel Crushers save system. (Neither integration's demo should use the UIS save system.) You don't have to use this test script in your own game, of course. It's just a convenient way to set up the demo scene.
Let's make sure manual saving and loading work first.
In the demo scene, I left verbose debugging on. Please play the Dialogue System integration's demo and pick up 2 Heal Weed. Then press 'i' to open the menu UI. Click the "Save / Load (DS)" button, then click Save. The Console should have lines similar to these:
Then exit play mode. Play the scene again. Press 'i' to open the menu UI. Click "Save / Load (DS)", then click Load. The Console should have lines similar to these:
Then verify that the player was loaded with 2 Heal Weed.
If that all looks good, try setting up the same thing in your own game. Make sure that manual saving and loading works first. You might want to tick the Debug checkboxes on the Pixel Crushers save system components to log the same info as above to the Console / Player.log file.
Once you know that works, try adding an Auto Save Load component.
Thanks for the detailed info.
The integration's demos tie into the original UIS demo's menu UI, but you'll notice that the save/load buttons aren't quite as pretty. This is because they use a simple save/load test script to save and load using the Pixel Crushers save system. (Neither integration's demo should use the UIS save system.) You don't have to use this test script in your own game, of course. It's just a convenient way to set up the demo scene.
Let's make sure manual saving and loading work first.
In the demo scene, I left verbose debugging on. Please play the Dialogue System integration's demo and pick up 2 Heal Weed. Then press 'i' to open the menu UI. Click the "Save / Load (DS)" button, then click Save. The Console should have lines similar to these:
Code: Select all
Save System: DiskSavedGameDataStorer loading C:/Users/.../UIS Integration/saveinfo.dat
Saving game to slot 0
Save System: DiskSavedGameDataStorer - Saving C:/Users/.../UIS Integration/save_0.dat: {"m_sceneName":"UIS DS Demo","m_list":[{"key":"UIS","sceneIndex":-1,"data":"{\"m_DateTimeTicks\":637369053757450294,\"m_SaveDataKeys\":...
Save System: DiskSavedGameDataStorer updating C:/Users/.../UIS Integration/saveinfo.dat
Code: Select all
Save System: DiskSavedGameDataStorer loading C:/Users/.../UIS Integration/saveinfo.dat
Loading game from slot 0
Save System: DiskSavedGameDataStorer - Loading C:/Users/.../UIS Integration/save_0.dat: {"m_sceneName":"UIS DS Demo","m_list":[{"key":"UIS","sceneIndex":-1,"data":"{\"m_DateTimeTicks\":637369053757450294,\"m_SaveDataKeys\":...
Save System: Loading scene UIS DS Demo
If that all looks good, try setting up the same thing in your own game. Make sure that manual saving and loading works first. You might want to tick the Debug checkboxes on the Pixel Crushers save system components to log the same info as above to the Console / Player.log file.
Once you know that works, try adding an Auto Save Load component.
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Trouble with saving
Thanks for taking the time on this Tony.
Saving in the DS+UIS Demo scene seems to be working. So I added the Auto Save Load component to the Pixel Crushers Save System gameobject to test it out. Play > Pick up heal weed > check inventory > quit play mode > Play. The heal weed was not in the inventory.
I'll work on getting the manual save/load working in my own game (I'll probably just scrap all the save components and rebuild them again using the demo. I must have missed something.) in the mean time, but any idea why the auto load save isn't working?
[Update] Manual save/load is now working in my game! That said, I'm running into a couple of issues.
- (1) Inventory is not persisting when I change scenes. I double checked that everything was set up correctly in my objects. For the time being, both Dialogue Manager and Quest Machine are set up in a prefab and exist in both scenes (is that ok?) The UIS Game object exists in both scenes as well (but isn't a prefab - don't think that should matter).
- (2) When I enter a new scene Quest Machine is throwing me a warning that it couldn't find the the quest with the ID of my quest (I only have one in the database at the moment). And if I return to the previous scene, the QM quest is reset.
Saving in the DS+UIS Demo scene seems to be working. So I added the Auto Save Load component to the Pixel Crushers Save System gameobject to test it out. Play > Pick up heal weed > check inventory > quit play mode > Play. The heal weed was not in the inventory.
I'll work on getting the manual save/load working in my own game (I'll probably just scrap all the save components and rebuild them again using the demo. I must have missed something.) in the mean time, but any idea why the auto load save isn't working?
[Update] Manual save/load is now working in my game! That said, I'm running into a couple of issues.
- (1) Inventory is not persisting when I change scenes. I double checked that everything was set up correctly in my objects. For the time being, both Dialogue Manager and Quest Machine are set up in a prefab and exist in both scenes (is that ok?) The UIS Game object exists in both scenes as well (but isn't a prefab - don't think that should matter).
- (2) When I enter a new scene Quest Machine is throwing me a warning that it couldn't find the the quest with the ID of my quest (I only have one in the database at the moment). And if I return to the previous scene, the QM quest is reset.
Re: Trouble with saving
Hi,
In addition, I see that UIS's Savers can take one frame to register themselves. To set up loading, you'll need to keep the AutoSaveLoad disabled at design time, and enable it after one frame. If you don't want to do any scripting, you can use a TimedEvent component:
Any of those techniques above tell the save system to save the current state to memory before leaving the old scene, and then apply the saved data (e.g., inventory) after loading the new scene.
Neither Unity's regular SceneManager.LoadScene() method nor UIS's save system (to my knowledge) handle persistence across scene changes, so you should use one of the techniques above.
Are you using Dialogue System 2.2.10 or higher and Quest Machine 1.2.10 or higher? They fix an AutoSaveLoad bug that was introduced in the previous versions. That will fix saving.cptscrimshaw wrote: ↑Mon Sep 28, 2020 5:25 pmSaving in the DS+UIS Demo scene seems to be working. So I added the Auto Save Load component to the Pixel Crushers Save System gameobject to test it out. Play > Pick up heal weed > check inventory > quit play mode > Play. The heal weed was not in the inventory.
In addition, I see that UIS's Savers can take one frame to register themselves. To set up loading, you'll need to keep the AutoSaveLoad disabled at design time, and enable it after one frame. If you don't want to do any scripting, you can use a TimedEvent component:
Change scenes using one of these techniques:cptscrimshaw wrote: ↑Mon Sep 28, 2020 5:25 pm- (1) Inventory is not persisting when I change scenes.
- ScenePortal component,
- SaveSystemMethods component's LoadScene() method,
- Dialogue System LoadLevel() sequencer command, or
- C# code:
Code: Select all
PixelCrushers.SaveSystem.LoadScene()
Any of those techniques above tell the save system to save the current state to memory before leaving the old scene, and then apply the saved data (e.g., inventory) after loading the new scene.
Neither Unity's regular SceneManager.LoadScene() method nor UIS's save system (to my knowledge) handle persistence across scene changes, so you should use one of the techniques above.
Are your quest assets assigned to a quest database asset? And is that quest database asset assigned to the Quest Machine GameObject?cptscrimshaw wrote: ↑Mon Sep 28, 2020 5:25 pm- (2) When I enter a new scene Quest Machine is throwing me a warning that it couldn't find the the quest with the ID of my quest (I only have one in the database at the moment). And if I return to the previous scene, the QM quest is reset.
-
- Posts: 113
- Joined: Sun Sep 20, 2020 8:21 pm
Re: Trouble with saving
You are a glorious human! Adding in the Scene Portal seemed to make everything else work. Auto Save/Load just started working too, which is kind of odd. I have the newest versions of both DS and GM.
It also doesn't appear that you need the frame delay for UIS loading to work properly.
A few more specific follow-up questions (let me know if I should move these to a separate thread):
1. If I wanted to "activate" a game object, like a quest pointer for example, in different scene from the one that started the quest, is there a way to tell Quest Machine to activate the object when the scene loads through some sort of action? Is there something built-in to handle this? If not, any suggestions on an approach?
2. Whenever the game loads and it is in the middle of a quest, the Quest Indicator Manager flashes the "!" before it disappears.
3. I've adjusted the look/position of the HUD and when I move around in the scene, it flashes/moves a little bit. Also, when I change scenes, it is positioned a little differently. I've triple-checked that all my settings are the same between scenes, though I'm sure this is something I just screwed up. Any idea where to look? Or is the HUD rendered in a way that may be causing this?
Thanks!
It also doesn't appear that you need the frame delay for UIS loading to work properly.
A few more specific follow-up questions (let me know if I should move these to a separate thread):
1. If I wanted to "activate" a game object, like a quest pointer for example, in different scene from the one that started the quest, is there a way to tell Quest Machine to activate the object when the scene loads through some sort of action? Is there something built-in to handle this? If not, any suggestions on an approach?
2. Whenever the game loads and it is in the middle of a quest, the Quest Indicator Manager flashes the "!" before it disappears.
3. I've adjusted the look/position of the HUD and when I move around in the scene, it flashes/moves a little bit. Also, when I change scenes, it is positioned a little differently. I've triple-checked that all my settings are the same between scenes, though I'm sure this is something I just screwed up. Any idea where to look? Or is the HUD rendered in a way that may be causing this?
Thanks!
Re: Trouble with saving
Hi,
Select Add Action > OnExecute() Event, and configure the event to do whatever you want, such as activating a GameObject.
If you're not using the Dialogue System, add a small script to check a quest state. Example:
It's a 50/50 shot. If the UIS Savers' OnEnable methods happen to run before AutoSaveLoad's Start method, then it will work. However, Unity does not guarantee the order of Start and OnEnable methods. In some situations, OnEnable could run first, but in other situations Start could run first. If you use the frame delay, you avoid the issue.cptscrimshaw wrote: ↑Tue Sep 29, 2020 7:07 pmIt also doesn't appear that you need the frame delay for UIS loading to work properly.
If I remember correctly, you're also using the Dialogue System. You can add a Dialogue System Trigger to the scene. Set it to OnStart. In Conditions > Lua Conditions, check a quest state. Example:cptscrimshaw wrote: ↑Tue Sep 29, 2020 7:07 pm1. If I wanted to "activate" a game object, like a quest pointer for example, in different scene from the one that started the quest, is there a way to tell Quest Machine to activate the object when the scene loads through some sort of action? Is there something built-in to handle this? If not, any suggestions on an approach?
Code: Select all
CurrentQuestState("myQuestID") == "active"
If you're not using the Dialogue System, add a small script to check a quest state. Example:
Code: Select all
using UnityEngine;
using UnityEngine.Events;
using PixelCrushers.QuestMachine;
public class QuestEventOnStart : MonoBehaviour
{
public StringField questID;
public QuestState requiredQuestState;
public UnityEvent onStart;
void Start()
{
if (QuestMachine.GetQuestState(questID) == requiredQuestState) onStart.Invoke();
}
}
That's because the NPC is instantiating its indicators, and then it disables them. To prevent the player from seeing this, set up a scene transition manager on the same GameObject as the Save System component. If you're using the Dialogue System, examine how the scene transition manager on its Dialogue Manager GameObject is set up.cptscrimshaw wrote: ↑Tue Sep 29, 2020 7:07 pm2. Whenever the game loads and it is in the middle of a quest, the Quest Indicator Manager flashes the "!" before it disappears.
Is the HUD still a child of the Quest Machine GameObject's Canvas? (It doesn't strictly have to be a child of this Canvas.) If it's a child of the Quest Machine's Canvas, it shouldn't move unless you've changed the canvas settings. It's just plain old Unity UI. Maybe take a look at the settings on the canvas and your customized HUD.cptscrimshaw wrote: ↑Tue Sep 29, 2020 7:07 pm3. I've adjusted the look/position of the HUD and when I move around in the scene, it flashes/moves a little bit. Also, when I change scenes, it is positioned a little differently. I've triple-checked that all my settings are the same between scenes, though I'm sure this is something I just screwed up. Any idea where to look? Or is the HUD rendered in a way that may be causing this?