Page 1 of 2
Quest Journal breaking between scenes
Posted: Tue May 25, 2021 9:03 pm
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?
Re: Quest Journal breaking between scenes
Posted: Tue May 25, 2021 9:20 pm
by mac
additional note: getting no errors in console, be it Quest Machine related or not.
Re: Quest Journal breaking between scenes
Posted: Tue May 25, 2021 9:38 pm
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.
Re: Quest Journal breaking between scenes
Posted: Tue May 25, 2021 10:08 pm
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?
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 8:08 am
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.
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 3:01 pm
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
}
}
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 3:25 pm
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.)
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 4:59 pm
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?
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 6:02 pm
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.
Re: Quest Journal breaking between scenes
Posted: Wed May 26, 2021 6:47 pm
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.