using asap.core; using GameCore; using UnityEngine; using UnityEngine.UI; public class SettingNotificationsPopupPanel : MonoBehaviour { public Button btn_ok; public Button btn_cancel; ILocalNotificationService notifications; bool handling; bool completed; private void Start() { notifications = GContext.container.Resolve(); btn_ok.onClick.AddListener(OnBtnOk); btn_cancel.onClick.AddListener(DestroyUI); } private async void OnBtnOk() { if (this == null || handling || completed) return; handling = true; try { if (notifications is LocalNotificationService local && local.HasKVPromptOwner) { local.RequirePromptOwner(); await local.OpenSettingsAsync(); if (this == null) return; local.RequirePromptOwner(); } else { DestroyUI(); notifications.OpenSettings(); return; } DestroyUI(); } catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); } finally { handling = false; } } void DestroyUI() { if (this == null || completed) return; try { (notifications as LocalNotificationService)?.RequirePromptOwner(); completed = true; UIManager.Instance.DestroyUI(gameObject.name); } catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); } } }