Page 1 of 1

Menu Framework Load Scene

Posted: Wed Dec 14, 2022 7:09 am
by dnblank12
Hi, I'm having an issue, I'm not sure if its unity in general issue or the menu framework, if I load Menu then Scene 1 again and again, afterwards the game froze, and I checked the profiler this shows (im new to profiler so idk)

Re: Menu Framework Load Scene

Posted: Wed Dec 14, 2022 7:15 am
by Tony Li
Hi,

There may be something in your Scene 1 that isn't cleaning up after itself or is getting into an infinite loop.

You could temporarily eliminate the Menu Framework from the possibilities by replacing the main menu scene with a small test scene that has a UI button to load Scene 1, and then add a UI button to Scene 1 that loads the main menu scene.

In fact, you could eliminate the Dialogue System's save system, too, by configuring the button to call SceneManager.Loadscene(), such as in this script:

Code: Select all

using UnityEngine;
using UnityEngine.SceneManagement;

public class BasicSceneLoader : MonoBehaviour
{
    public void LoadScene(string sceneName) // <-- Configure UI button's OnClick() to use this.
    {
        SceneManager.LoadScene(sceneName);
    }
}
If that works, try replacing SceneManager.LoadScene(sceneName) with:

Code: Select all

PixelCrushers.SaveSystem.LoadScene(sceneName);
This will involve the save system but not the Menu Framework.

Re: Menu Framework Load Scene

Posted: Thu Dec 15, 2022 3:33 am
by dnblank12
Hi, I tried it on a new empty project, and used the code you suggested, and the issue is still there. I tried another profiler with deep profile (for some reason the first post screenshot didn't show it)

Re: Menu Framework Load Scene

Posted: Fri Dec 16, 2022 8:50 am
by dnblank12

Code: Select all

        public virtual void ReturnToTitleMenu()
        {
            SaveSystem.BeforeSceneChange();
            SaveSystem.LoadScene("index:" + FindObjectOfType<TitleMenu>().titleSceneIndex);
            //SaveSystem.sceneLoaded += OpenTitleMenuOnSceneLoaded;
        }

        private void OpenTitleMenuOnSceneLoaded(string sceneName, int sceneIndex)
        {
            //SaveSystem.sceneLoaded += OpenTitleMenuOnSceneLoaded;
            FindObjectOfType<TitleMenu>().titleMenuPanel.Open();
        }
so I comment out the SaveSystem.sceneLoaded += OpenTitleMenuOnSceneLoaded and it actually worked.

Re: Menu Framework Load Scene

Posted: Fri Dec 16, 2022 10:48 am
by Tony Li
Thank you for the info. I’ll check the original Menu Framework code to make sure it’s properly using “-=“ to unhook.