From 4797175307410d66be9f9185b33c378b43360645 Mon Sep 17 00:00:00 2001 From: _nebula <41904486+misternebula@users.noreply.github.com> Date: Fri, 10 Nov 2023 13:40:30 +0000 Subject: [PATCH] fix some popups appearing underneath menus --- .../CustomInputs/OWMLFourChoicePopupMenu.cs | 3 +++ .../CustomInputs/OWMLPopupInputMenu.cs | 12 ++++++++++++ .../CustomInputs/OWMLThreeChoicePopupMenu.cs | 3 +++ 3 files changed, 18 insertions(+) diff --git a/src/OWML.ModHelper.Menus/CustomInputs/OWMLFourChoicePopupMenu.cs b/src/OWML.ModHelper.Menus/CustomInputs/OWMLFourChoicePopupMenu.cs index 9134981c..9cdfbb91 100644 --- a/src/OWML.ModHelper.Menus/CustomInputs/OWMLFourChoicePopupMenu.cs +++ b/src/OWML.ModHelper.Menus/CustomInputs/OWMLFourChoicePopupMenu.cs @@ -129,9 +129,12 @@ public override void InitializeMenu() _ok1Action.OnSubmitAction += InvokeOk1; _ok2Action.OnSubmitAction += InvokeOk2; _ok3Action.OnSubmitAction += InvokeOk3; + // PopupCanvas is disabled after the menus are initialized, and overrideSorting can only be set when it's enabled + _menuActivationRoot.gameObject.SetActive(true); _popupCanvas = gameObject.GetAddComponent(); _popupCanvas.overrideSorting = true; _popupCanvas.sortingOrder = 30000; + _menuActivationRoot.gameObject.SetActive(false); gameObject.GetAddComponent(); gameObject.GetAddComponent(); } diff --git a/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs b/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs index b676b347..1b6b4a72 100644 --- a/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs +++ b/src/OWML.ModHelper.Menus/CustomInputs/OWMLPopupInputMenu.cs @@ -24,6 +24,18 @@ public override void Awake() this._inputField.DeactivateInputField(); } + public override void InitializeMenu() + { + base.InitializeMenu(); + + // PopupCanvas is disabled after the menus are initialized, and overrideSorting can only be set when it's enabled + _menuActivationRoot.gameObject.SetActive(true); + _popupCanvas = gameObject.GetAddComponent(); + _popupCanvas.overrideSorting = true; + _popupCanvas.sortingOrder = 30000; + _menuActivationRoot.gameObject.SetActive(false); + } + public override Selectable GetSelectOnActivate() { return this._selectOnActivate; diff --git a/src/OWML.ModHelper.Menus/CustomInputs/OWMLThreeChoicePopupMenu.cs b/src/OWML.ModHelper.Menus/CustomInputs/OWMLThreeChoicePopupMenu.cs index c0313a93..c600365c 100644 --- a/src/OWML.ModHelper.Menus/CustomInputs/OWMLThreeChoicePopupMenu.cs +++ b/src/OWML.ModHelper.Menus/CustomInputs/OWMLThreeChoicePopupMenu.cs @@ -117,9 +117,12 @@ public override void InitializeMenu() _ok1Action.OnSubmitAction += InvokeOk1; _ok2Action.OnSubmitAction += InvokeOk2; + // PopupCanvas is disabled after the menus are initialized, and overrideSorting can only be set when it's enabled + _menuActivationRoot.gameObject.SetActive(true); _popupCanvas = gameObject.GetAddComponent(); _popupCanvas.overrideSorting = true; _popupCanvas.sortingOrder = 30000; + _menuActivationRoot.gameObject.SetActive(false); gameObject.GetAddComponent(); gameObject.GetAddComponent(); }