This commit is contained in:
舒荣森 2024-11-26 18:19:49 +08:00
parent a635cdf650
commit 71a9d3292f
2 changed files with 5 additions and 3 deletions

View File

@ -10,14 +10,15 @@ public class EventPopUp : MonoBehaviour
public string text = "";
public Image Image;
public Text textobg;
public float time = 5f;
async void Start()
{
Canvas canvas = GetComponentInParent<Canvas>();
float canvasHeight = canvas.GetComponent<RectTransform>().rect.height;
transform.DOMoveY(canvasHeight - (canvasHeight*0.3f), 1.5f);
await Task.Delay(500);
Image.DOColor(new Color(1f, 1f, 1f, 0f), 5f);
textobg.DOColor(new Color(1f, 1f, 1f, 0f), 5f);
Image.DOColor(new Color(1f, 1f, 1f, 0f), time);
textobg.DOColor(new Color(1f, 1f, 1f, 0f), time);
await Task.Delay(5100);
Destroy(gameObject);
}

View File

@ -31,9 +31,10 @@ public class Base : MonoBehaviour
await tcs.Task;
}
public void addEventPopUp(string Details)//Ìí¼Óµ¯´°
public void addEventPopUp(string Details,float time = 5f)//Ìí¼Óµ¯´°
{
GameObject prefab = Resources.Load<GameObject>("base/EventPopUp");
prefab.GetComponent<EventPopUp>().time = time;
Canvas canvas = GetComponentInParent<Canvas>();
prefab.GetComponent<EventPopUp>().text = Details;
Instantiate(prefab, canvas.transform);