_TheStrongestSnail/TheStrongestSnail/Assets/common/base/EventPopUp.cs

33 lines
795 B
C#
Raw Normal View History

2024-11-25 23:31:50 +08:00
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<Canvas>();
float canvasHeight = canvas.GetComponent<RectTransform>().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;
}
}
}