1、建立两个UISprite。
2、建立脚本CountingTime
3、编写脚本
public class CountTime : MonoBehaviour { //时间计时器 public float countTime; //倒计时显示 public UILabel timeCount; //计时条在准备后隐藏 public float prograssPercent = 1f; public UISprite jinDuTiao; // Update is called once per frame void Update() { if (countTime <= 60 ) { countTime += Time.deltaTime; timeCount.text = (60f - countTime).ToString("F0"); prograssPercent -= (1f / 60f) * Time.deltaTime; jinDuTiao.fillAmount = prograssPercent; } } }
主要是UIsprite.fillAmount的应用,注意Fill Dir要改成Horizontal,水平。
写的一般,不知道大家能不能理解,慢研究吧,哈哈!