| 123456789101112131415161718192021222324252627282930 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using DG.Tweening;
- public class StartTimer : MonoBehaviour
- {
- int time = 3;
- void Start()
- {
- this.ChangeTime();
- }
- void ChangeTime()
- {
- this.transform.localScale = new Vector3(1, 1, 1);
- this.GetComponent<Text>().text = this.time > 0 ? this.time.ToString() : "开始";
- this.transform.DOScale(new Vector3(0.75f, 0.75f, 1), 0.8f).OnComplete(delegate() {
- this.time--;
- if (this.time >= 0)
- {
- this.ChangeTime();
- } else {
- Destroy(this.gameObject);
- }
- });
- }
- }
|