diff --git a/ModalManager.cs b/ModalManager.cs index 0361910..8881d6c 100644 --- a/ModalManager.cs +++ b/ModalManager.cs @@ -22,17 +22,26 @@ namespace KCM { if (!instantiated) { + // Check if modal prefab is loaded + if (PrefabManager.modalUIPrefab == null) + { + Main.helper.Log("WARNING: ModalManager cannot initialize - modalUIPrefab is null (asset bundle missing)"); + instantiated = true; // Prevent re-initialization attempts + return; + } + modalInst = GameObject.Instantiate(PrefabManager.modalUIPrefab, Constants.MainMenuUI_T); modalInst.SetActive(false); acceptButton = modalInst.transform.Find("Modal/Container/Button").GetComponent(); - + tmpTitle = modalInst.transform.Find("Modal/Container/Title").GetComponent(); tmpDescription = modalInst.transform.Find("Modal/Container/Description").GetComponent(); instantiated = true; + Main.helper.Log("ModalManager initialized successfully"); } else { @@ -42,6 +51,13 @@ namespace KCM public static void ShowModal(string title, string message, string buttonText = "Okay", bool withButton = true, Action action = null) { + // If modal couldn't be initialized (asset bundle missing), just log the message + if (modalInst == null) + { + Main.helper.Log($"MODAL (not shown - UI missing): {title} - {message}"); + return; + } + tmpTitle.text = title; tmpDescription.text = message; @@ -62,7 +78,10 @@ namespace KCM public static void HideModal() { - modalInst.SetActive(false); + if (modalInst != null) + { + modalInst.SetActive(false); + } } } }