using DG.Tweening; using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; using UnityEngine; using UnityEngine.UI; public class Base : MonoBehaviour { public async Task ButtonClickAnimationAsync(GameObject button) { TaskCompletionSource tcs = new TaskCompletionSource(); Sequence mySequence = DOTween.Sequence(); mySequence.Append(button.transform.DOScale(1.25f, 0.1f)) // 第一个动画 .Append(button.transform.DOScale(1f, 0.2f)).OnComplete(() => { // 动画播放完成后执行的代码 tcs.SetResult(true); }); // 第二个动画 await tcs.Task; } public void addEventPopUp(string Details) { GameObject prefab = Resources.Load("base/EventPopUp"); Canvas canvas = GetComponentInParent(); prefab.GetComponent().text = Details; Instantiate(prefab, canvas.transform); } }