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 twcFade = null; public void Init() { canvasPopup = GetComponent(); txtMsg = transform.Find("txtMsg").GetComponent(); } 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(); } }