From 9e2a6777aff2bd89cb591dcaee4a183f3a900a59 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Tue, 2 Aug 2022 12:24:18 -0700 Subject: [PATCH] dont create popup prefab if it already exists --- QSB/Menus/MenuManager.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/QSB/Menus/MenuManager.cs b/QSB/Menus/MenuManager.cs index 4c70ee19..636803a0 100644 --- a/QSB/Menus/MenuManager.cs +++ b/QSB/Menus/MenuManager.cs @@ -54,9 +54,12 @@ internal class MenuManager : MonoBehaviour, IAddComponentOnStart { Instance = this; - _choicePopupPrefab = Instantiate(Resources.FindObjectsOfTypeAll().First(x => x.name == "TwoButton-Popup" && x.transform.parent.name == "PopupCanvas" && x.transform.parent.parent.name == "TitleMenu").gameObject); - DontDestroyOnLoad(_choicePopupPrefab); - _choicePopupPrefab.SetActive(false); + if (!_choicePopupPrefab) + { + _choicePopupPrefab = Instantiate(Resources.FindObjectsOfTypeAll().First(x => x.name == "TwoButton-Popup" && x.transform.parent.name == "PopupCanvas" && x.transform.parent.parent.name == "TitleMenu").gameObject); + DontDestroyOnLoad(_choicePopupPrefab); + _choicePopupPrefab.SetActive(false); + } MakeTitleMenus(); QSBSceneManager.OnSceneLoaded += OnSceneLoaded;