You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
1.9 KiB

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<TextMeshProUGUI>();
txtMsg = transform.Find("txtMsg").GetComponent<TextMeshProUGUI>();
txtBtnYes = transform.Find("btnYes").Find("txt").GetComponent<TextMeshProUGUI>();
}
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();
}
}