using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using DG.Tweening; using UnityEngine.UI; public class CountDownAnimation : PFUIPanel { // Start is called before the first frame update void Start() { } public void StartTime(UnityAction action,UnityAction action2) { HandleAnimation("5", action, action2); } void HandleAnimation(string s, UnityAction action, UnityAction action2) { var text = transform.Find("Text"); text.GetComponent().text = s; text.transform.GetComponent().DOScale(Vector3.one * 2, 0.5f).onComplete = () => { text.GetComponent().DOScale(Vector3.one * 0.5f, 0.5f).onComplete = ()=> { if (s == "Go") { action.Invoke(); gameObject.SetActive(false); return; } var flag = int.TryParse(s,out int a); Debug.Log(a); if (flag) { if (a == 1 && action2 != null) { action2.Invoke(); } if (a - 1 == 0) { HandleAnimation("Go", action, action2); } else { HandleAnimation((a - 1).ToString(), action, action2); } } }; }; } // Update is called once per frame void Update() { } }