Shegotwet/Assets/Scripts/UI/ToastUI.cs

20 lines
453 B
C#

using TMPro;
using UnityEngine;
public class ToastUI : MonoBehaviour
{
public RectTransform rt_bg;
public TextMeshProUGUI t_mgs;
public void Set(string text)
{
gameObject.SetActive(true);
t_mgs.text = text;
rt_bg.sizeDelta = new Vector2(rt_bg.sizeDelta.x, t_mgs.preferredHeight + 50);
if (IsInvoking()) CancelInvoke();
Invoke("Off", 3f);
}
void Off() { gameObject.SetActive(false); }
}