31 lines
976 B
C#
31 lines
976 B
C#
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<bool> tcs = new TaskCompletionSource<bool>();
|
|
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<GameObject>("base/EventPopUp");
|
|
Canvas canvas = GetComponentInParent<Canvas>();
|
|
prefab.GetComponent<EventPopUp>().text = Details;
|
|
Instantiate(prefab, canvas.transform);
|
|
}
|
|
|
|
}
|