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; public float time = 5f; async void Start() { Canvas canvas = GetComponentInParent(); float canvasHeight = canvas.GetComponent().rect.height; transform.DOMoveY(canvasHeight - (canvasHeight*0.3f), 1.5f); await Task.Delay(500); Image.DOColor(new Color(1f, 1f, 1f, 0f), time); textobg.DOColor(new Color(1f, 1f, 1f, 0f), time); await Task.Delay(5100); Destroy(gameObject); } // Update is called once per frame void Update() { if (textobg != null) { textobg.text = text; } } }