using UnityEngine; using TMPro; public class IVPp1Button : MonoBehaviour { protected TextMeshProUGUI txtTitle; protected TextMeshProUGUI txtMsg; protected TextMeshProUGUI txtBtnYes; protected System.Action actionBtnYes; protected bool bClose = true; protected int iGroup = -1; public bool IsOpen() { return gameObject.activeSelf; } public virtual void Init() { txtTitle = transform.Find("txtTitle").GetComponent(); txtMsg = transform.Find("txtMsg").GetComponent(); txtBtnYes = transform.Find("btnYes").Find("txt").GetComponent(); } public void Open(string strmsg, System.Action actionyes = null, string strtitle = null, string stryes = null, bool bclose = true, float ftime = 0f, int igroup = -1) { CancelInvoke("Close"); if (string.IsNullOrEmpty(strtitle)) strtitle = LocalizationText.GetText(Global.STR_CONFIRM); if (string.IsNullOrEmpty(stryes)) stryes = LocalizationText.GetText(Global.STR_OK); txtTitle.text = strtitle; txtMsg.text = strmsg; txtBtnYes.text = stryes; actionBtnYes = actionyes; bClose = bclose; iGroup = igroup; gameObject.SetActive(true); if (ftime > 0f) Invoke("Close", ftime); } public virtual void CloseGroup(int igroup) { if (iGroup != igroup) return; BtnYesPressed(); } protected void Close() { GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); } public void BtnYesPressed() { SoundMgr.Instance.PlaySfx(SoundName.BtnPress); CancelInvoke("Close"); if (bClose) { GameUIMgr.SOnClosePopup(); gameObject.SetActive(false); } if (actionBtnYes != null) actionBtnYes.Invoke(); } }