Quest Journal breaking between scenes

Announcements, support questions, and discussion for Quest Machine.
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Quest Journal breaking between scenes

Post by mac »

Hey Tony, my quest journal gets empty and unresponsive (no buttons or input can close it after its opened) when loading a different scene, also the quest HUD goes missing. How can I make sure those are consistent between scenes?
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Quest Journal breaking between scenes

Post by mac »

additional note: getting no errors in console, be it Quest Machine related or not.
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Journal breaking between scenes

Post by Tony Li »

Hi,

Can you set up the save system? (The Dialogue System Extras page has a SaveSystemPrefabs package that's compatible with Quest Machine, too. It has preconfigured prefabs that you can just drop into the scene.)

If so, change scenes using one of the save system methods:
  • ScenePortal component
  • C#: SaveSystem.LoadScene()
  • Hook up a UnityEvent to a SaveSystemMethods component's LoadScene method
The save system will record the quest journal's data to memory before leaving the old scene. After entering the new scene, it will restore the saved data from memory to the new scene's quest journal and tell the HUD to update with the restored data.
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Quest Journal breaking between scenes

Post by mac »

I will start using Easy Save 3 soon, is there any additional steps for Easy Save 3? Do I have to set it up now or can I implement the compatibility later when I install Easy Save 3?
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Journal breaking between scenes

Post by Tony Li »

You can install compatibility later. It's just a matter of removing the PlayerPrefsSavedGameDataStorer component and adding an ESSavedGameDataStorer in its place.
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Quest Journal breaking between scenes

Post by mac »

Understood, I'm using a loading screen script for changing scenes, how can I replace the

Code: Select all

SceneManager.LoadSceneAsync(scene);
That this script uses?

Heres the full script:

Code: Select all

using UnityEngine;
using Lovatto.SceneLoader;
#if UNITY_5_3|| UNITY_5_4 || UNITY_5_3_OR_NEWER || UNITY_2017
using UnityEngine.SceneManagement;
#endif

public static class bl_SceneLoaderUtils
{
    /// <summary>
    /// 
    /// </summary>
    public static bl_SceneLoader GetLoader
    {
        get
        {
            bl_SceneLoader sl = GameObject.FindObjectOfType<bl_SceneLoader>();
            if(sl == null)
            {
                Debug.LogWarning("Don't have any scene loader in this scene.");
            }
            return sl;
        }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <returns></returns>
    public static bl_SceneLoaderManager GetSceneLoaderManager()
    {
        bl_SceneLoaderManager slm = Resources.Load("SceneLoaderManager", typeof(bl_SceneLoaderManager)) as bl_SceneLoaderManager;
        if(slm == null)
        {
            Debug.LogWarning("Not found any scene loader manager in resources folder!");
        }
        return slm;
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="scene"></param>
    public static AsyncOperation LoadLevelAsync(int scene)
    {
#if UNITY_5_3 || UNITY_5_4|| UNITY_5_3_OR_NEWER || UNITY_2017
       return SceneManager.LoadSceneAsync(scene);
#else
        return Application.LoadLevelAsync(scene);
#endif
    }

    /// <summary>
    /// 
    /// </summary>
    /// <param name="scene"></param>
    public static AsyncOperation LoadLevelAsync(string scene)
    {
#if UNITY_5_3 || UNITY_5_4|| UNITY_5_3_OR_NEWER || UNITY_2017
        return  SceneManager.LoadSceneAsync(scene);
#else
        return Application.LoadLevelAsync(scene);
#endif
    }

}
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Journal breaking between scenes

Post by Tony Li »

Replace this:

Code: Select all

return SceneManager.LoadSceneAsync(scene);
with this:

Code: Select all

PixelCrushers.SaveSystem.LoadScene(scene);
return PixelCrushers.SaveSystem.currentAsyncOperation;
(BTW, Quest Machine's save system has an optional scene transition / loading screen component. The SaveSystem GameObject in the SaveSystemPrefabs package is preconfigured with it.)
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Quest Journal breaking between scenes

Post by mac »

Everything is working now! Thank you Tony.
Another small question: where can I edit the Journal UI Hide function? (Used for closing the Journal)
I have some things I would like to add to the function, such as unhiding the cursor, stop character from moving while the menu is open and so on.

But when I try to edit the script that calls the hide function, this i what I get:

Code: Select all

// Copyright (c) Pixel Crushers. All rights reserved.

using UnityEngine;

namespace PixelCrushers.QuestMachine.Wrappers
{

    /// <summary>
    /// This wrapper class keeps references intact if you switch between the 
    /// compiled assembly and source code versions of the original class.
    /// </summary>
    [AddComponentMenu("Pixel Crushers/Quest Machine/UI/Unity UI Quest Journal UI")]
    public class UnityUIQuestJournalUI : PixelCrushers.QuestMachine.UnityUIQuestJournalUI
    {
    }

}
Should I add overrides to this script?
User avatar
Tony Li
Posts: 21928
Joined: Thu Jul 18, 2013 1:27 pm

Re: Quest Journal breaking between scenes

Post by Tony Li »

Hi,

That (PixelCrushers.QuestMachine.Wrappers.UnityUIQuestJournalUI) a subclass of the real class
(PixelCrushers.QuestMachine.UnityUIQuestJournalUI). You can subclass it:

Code: Select all

using PixelCrushers.QuestMachine;

public class MyQuestJournalUI : UnityUIQuestJournalUI
{
    // Override methods here
}
However, it already has a UIPanel component with OnOpen() and OnClose() UnityEvents that you can hook up in the inspector or in script. Example in script:

Code: Select all

var journalUI = QuestMachine.defaultQuestJournalUI as UnityUIQuestJournalUI;
var uiPanel = journalUI.GetComponent<UIPanel>();
uiPanel.onOpen.AddListener(DisablePlayerMovement);
uiPanel.onClose.AddListener(EnablePlayerMovement);
That way you don't need to subclass anything.
mac
Posts: 81
Joined: Sat Aug 22, 2020 7:54 pm

Re: Quest Journal breaking between scenes

Post by mac »

Ok,

Code: Select all

var journalUI = QuestMachine.defaultQuestJournalUI as UnityUIQuestJournalUI;
var uiPanel = journalUI.GetComponent<UIPanel>();
uiPanel.onOpen.AddListener(DisablePlayerMovement);
uiPanel.onClose.AddListener(EnablePlayerMovement);
But where would I put this? In the wrapper subclass?

And if I understood correctly all I would have to do is:

Code: Select all

var journalUI = QuestMachine.defaultQuestJournalUI as UnityUIQuestJournalUI;
var uiPanel = journalUI.GetComponent<UIPanel>();
var uiManager = FindObjectOfType<UIManager>();
uiPanel.onOpen.AddListener(uiManager.ToggleJournal);
uiPanel.onClose.AddListener(uiManager.ToggleJournal); 
Since this is the specific script and method I want to call whenever the journal is opened or closed.
Post Reply