赞
踩
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class DaoJiShi : MonoBehaviour { public float time = 100; public Text text; private void Start() { text = transform.Find("Text").GetComponent<Text>(); text.text = $"{(int)time / 60:D1}:{(int)time % 60:D2}"; StartCoroutine(Count()); } private IEnumerator Count() { while (time > 0) { yield return new WaitForSeconds(1); time--; text.text = $"{(int)time / 60:D1}:{(int)time % 60:D2}"; } } }
private int fromNumber = 0;
private int toNumber = 50;
private int duration = 10;
void Update()
{
text.text = number.ToString();
}
public void CountDown()
{
DOTween.To(() => fromNumber, x => fromNumber= x, toNumber, duration).SetEase(Ease.Linear);
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。