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.
 
 
 
 
 
 

50 lines
1.2 KiB

using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using TMPro;
using UnityEngine;
public class IVPpToast : MonoBehaviour
{
protected CanvasGroup canvasPopup;
protected TextMeshProUGUI txtMsg;
protected TweenerCore<float, float, FloatOptions> twcFade = null;
public void Init()
{
canvasPopup = GetComponent<CanvasGroup>();
txtMsg = transform.Find("txtMsg").GetComponent<TextMeshProUGUI>();
}
public bool IsOpen()
{
return gameObject.activeSelf;
}
public void Open(string strmsg, float ftime)
{
if (twcFade != null && twcFade.IsPlaying())
twcFade.Pause();
if (gameObject.activeSelf)
GameUIMgr.SOnClosePopup();
txtMsg.text = strmsg;
canvasPopup.alpha = 1f;
gameObject.SetActive(true);
if (twcFade == null)
{
twcFade = canvasPopup.DOFade(0f, 0.3f).SetDelay(ftime).SetAutoKill(false).SetUpdate(true).OnComplete(() =>
{
GameUIMgr.SOnClosePopup();
gameObject.SetActive(false);
}).Pause();
}
else
{
twcFade = twcFade.SetDelay(ftime);
}
twcFade.Restart();
}
}