Question about active saver

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Lucian1899
Posts: 23
Joined: Wed Dec 13, 2023 9:23 am

Question about active saver

Post by Lucian1899 »

Hi,

I have an UI canvas in my first scene and set it as DontDestoryOnLoad,it has several layers and many child objects, and I add an active saver component to it. During the game, some of its child objects will become active, but here comes the save problem.

I use On Conversation End trigger to activate those child objects, their active state can be saved when I change sences, S/L, back to main menu(only in play mode).but when I back to edit mode and play the game again, I found their active state can not be saved when I load the game. Could you please tell me which step I did wrong, or I missed something? Thank you!
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about active saver

Post by Tony Li »

Hi,

ActiveSaver and MultiActiveSaver components must be on GameObjects that are active when the scene starts. Is your ActiveSaver component on a GameObject that is active when the scene starts?

When you enter play mode a second time, are you loading a saved game? The save system will not automatically restore your last saved game. You can use an AutoSaveLoad component to do this, or you can load a saved game manually using the C# method SaveSystem.LoadFromSlot(#) or SaveSystemMethods component.
Lucian1899
Posts: 23
Joined: Wed Dec 13, 2023 9:23 am

Re: Question about active saver

Post by Lucian1899 »

Hi,
ActiveSaver and MultiActiveSaver components must be on GameObjects that are active when the scene starts. Is your ActiveSaver component on a GameObject that is active when the scene starts?
Yes, the father object is active when the scene starts.
When you enter play mode a second time, are you loading a saved game? The save system will not automatically restore your last saved game. You can use an AutoSaveLoad component to do this, or you can load a saved game manually using the C# method SaveSystem.LoadFromSlot(#) or SaveSystemMethods component.
I think I loaded a saved game, I'm using the Dialogue System Menu Framework. Here are my menu system and dialogue system, I don't know if I did something wrong, thank you!
Attachments
2.png
2.png (27.81 KiB) Viewed 113 times
1.png
1.png (27.18 KiB) Viewed 113 times
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about active saver

Post by Tony Li »

How are you changing scenes? Please see How To: Change Scenes With Save System. See also: How To: Manage Player Controls and Scene Changes.

When you're in the main menu scene, are you using the "Load Game" or "Continue" buttons to load a saved game?
Lucian1899
Posts: 23
Joined: Wed Dec 13, 2023 9:23 am

Re: Question about active saver

Post by Lucian1899 »

Hi,
How are you changing scenes?
I use PixelCrushers.SaveSystem.LoadScene("sceneName").
When you're in the main menu scene, are you using the "Load Game" or "Continue" buttons to load a saved game?
Yes, I use LoadGamePanel.LoadCurrentSlot() and SaveHelper.LoadLastSavedGame.

I've tried to watch a regular GameObject's active state in another scene, and it can saved perfectly. So I think maybe the UI canvas itself has the problem. Here's my custom persistent singleton script, I'm not sure if it is correct and related to this problem.

Code: Select all

using UnityEngine;

public class DontDestroy : MonoBehaviour
{
    private static DontDestroy instance; 

    private void Awake()
    {
        if (instance == null)
        {
            instance = this; 
            DontDestroyOnLoad(gameObject); 
        }
        else
        {
            Destroy(gameObject); 
        }
    }
}
And actually, the UI canvas is using this Dynamic Panel, https://github.com/yasirkula/UnityDynam ... me-ov-file, so I'm not sure if I should customize that Dynamic Panels Canvas script, or I should write a custom saver? Thank you!
User avatar
Tony Li
Posts: 23431
Joined: Thu Jul 18, 2013 1:27 pm

Re: Question about active saver

Post by Tony Li »

Hi,

Is it possible that the ActiveSaver or some other component is losing its reference to the Don't Destroy On Load GameObject? Please see the How To: Manage Player Controls and Scene Changes link above for an explanation of how this can happen and how to address it.
Post Reply