public void ShowMessage(MesSetting mesSetting) { if (Tr.gameObject.activeSelf) { popMesSettings.Add(mesSetting); } else { Tr.gameObject.SetActive(true); if (coroutineShow != null) { GameApp.Ins.StopCoroutine(coroutineShow); } coroutineShow = GameApp.Ins.StartCoroutine(ShowMessageDelay(mesSetting)); } }
IEnumerator ShowMessageDelay(MesSetting mesSetting) { Tr.SetAsLastSibling(); btnok.gameObject.SetActive(false); btncancel.gameObject.SetActive(false); content.text = mesSetting.content; title.text = mesSetting.title; float h = content.preferredHeight; yield return(null); //AjHeight(h, mesSetting.btnType != BtnType.Non); RegistBtn(mesSetting); }
private void RegistBtn(MesSetting mesSetting) { if (mesSetting.btnType != BtnType.Non) { if (mesSetting.btnType == BtnType.Ok) { btnok.gameObject.SetActive(true); if (mesSetting.btnoktext != null) { btnok.GetComponentInChildren <Text>().text = mesSetting.btnoktext; } btnok.onClick.RemoveAllListeners(); btnok.onClick.AddListener(() => { InvokeMes(mesSetting.action, 1); }); btncancel.gameObject.SetActive(false); } else if (mesSetting.btnType == BtnType.Cancel) { btnok.gameObject.SetActive(true); btncancel.gameObject.SetActive(true); if (mesSetting.btnoktext != null) { btnok.GetComponentInChildren <Text>().text = mesSetting.btnoktext; } if (mesSetting.btncanceltext != null) { btncancel.GetComponentInChildren <Text>().text = mesSetting.btncanceltext; } btnok.onClick.RemoveAllListeners(); btnok.onClick.AddListener(() => { InvokeMes(mesSetting.action, 1); }); btncancel.onClick.RemoveAllListeners(); btncancel.onClick.AddListener(() => { InvokeMes(mesSetting.action, 0); }); } } }