diff --git a/src/OWML.ModHelper.Menus/NewMenuSystem/Patches.cs b/src/OWML.ModHelper.Menus/NewMenuSystem/Patches.cs index adde2a36..a8371c2c 100644 --- a/src/OWML.ModHelper.Menus/NewMenuSystem/Patches.cs +++ b/src/OWML.ModHelper.Menus/NewMenuSystem/Patches.cs @@ -121,5 +121,22 @@ public static void FadeInTitleLogo(TitleScreenManager __instance) var owmlManifest = JsonHelper.LoadJsonObject($"{Application.dataPath}/Managed/{Constants.OwmlManifestFileName}"); __instance._gameVersionTextDisplay.text = $"Outer Wilds : {Application.version}{Environment.NewLine}OWML : {owmlManifest.Version}"; } + + [HarmonyPostfix] + [HarmonyPatch(typeof(PopupMenu), nameof(PopupMenu.EnableMenu))] + public static void EnableMenu(PopupMenu __instance) + { + var rootEnabled = __instance._menuActivationRoot.gameObject.activeSelf; + + // PopupCanvas is disabled after the menus are initialized, and overrideSorting can only be set when it's enabled + __instance._menuActivationRoot.gameObject.SetActive(true); + __instance._popupCanvas = __instance.gameObject.GetAddComponent(); + __instance._popupCanvas.overrideSorting = true; + __instance._popupCanvas.sortingOrder = 30000; + if (!rootEnabled) + { + __instance._menuActivationRoot.gameObject.SetActive(false); + } + } } }