UGUI Image显示倒计时
程序员文章站
2022-05-30 17:38:11
...
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class UIResume : MonoBehaviour
{
public Image imgCount; //Image
public Sprite[] spCount;//Sprite
public void StartCount()
{
Show();
StartCoroutine(StartCountCor());//开始倒计时
}
IEnumerator StartCountCor()
{
int i = 3;
while (i > 0)
{
imgCount.sprite = spCount[i - 1];
i--;
yield return new WaitForSeconds(1);//等待1秒
if (i <= 0)
{
break;
}
}
}
}
上一篇: Ugui滑动翻页