/// <summary> /// 订阅暂停事件 /// </summary> private void SubscribeEvent() { Main.m_Event.Subscribe <PauseEventHandler>((sender, e) => { if ((e as PauseEventHandler).Paused) { if ((e as PauseEventHandler).NeedOpenPauseMenu) { Main.m_UI.OpenUI <PauseUILogic>(); } } else if ((e as PauseEventHandler).NeedOpenPauseMenu) { UIShowHideHelper.HideToUp(UIEntity); MainThread.Instance.DelayAndRun(300, Main.m_UI.CloseUI <PauseUILogic>); } }); }
/// <summary> /// 初始化 /// </summary> public override void OnInit() { Data = new ModelDialogModel(); foreach (var item in UIEntity.GetComponentsInChildren <Text>(true)) { if (item.gameObject.name.Equals("Title")) { Title = item; } else if (item.gameObject.name.Equals("Message")) { Message = item; } else if (item.gameObject.transform.parent.gameObject.name.Equals("ConfirmButton")) { ConfirmText = item; ConfirmButton = item.gameObject.transform.parent.gameObject.GetComponent <Button>(); } else if (item.gameObject.transform.parent.gameObject.name.Equals("CancelButton")) { CancelText = item; CancelButton = item.gameObject.transform.parent.gameObject.GetComponent <Button>(); } } base.OnInit(); CancelButton.onClick.AddListener(() => { UIShowHideHelper.HideToUp(UIEntity); Data.CancelAction?.Invoke(); NavigateBack(); }); ConfirmButton.onClick.AddListener(() => { UIShowHideHelper.HideToUp(UIEntity); Data.ConfirmAction?.Invoke(); NavigateBack(); }); }