using DG.Tweening; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; public class EventPopUp : MonoBehaviour { public string text = ""; public Image Image; public Text textobg; async void Start() { Canvas canvas = GetComponentInParent(); float canvasHeight = canvas.GetComponent().rect.height; transform.DOMoveY(canvasHeight - 200f, 1.5f); await Task.Delay(500); Image.DOColor(new Color(1f, 1f, 1f, 0f), 5f); await Task.Delay(5000); Destroy(gameObject); } // Update is called once per frame void Update() { if (textobg != null) { textobg.text = text; } } }