public class jishiqi : MonoBehaviour
{
Image m_image;
Text m_text;
void Start ()
{
m_image = GetComponent <Image> ();
m_text = GameObject.Find ("Text").GetComponent <Text> ();
m_image.fillAmount = 0f;
m_text.text = "5";
}
void Update ()
{
//time.deltaTime是一秒,实现一秒图片完成一次填充。
m_image.fillAmount += Time.deltaTime;
if (m_image.fillAmount >= 1) {
m_image.fillAmount = 0;
m_text.text = (int.Parse (m_text.text) - 1).ToString ();
if (m_text.text == "0") {
m_text.text = "5";
}
}
}
}
是倒计时5s ,不断的执行,要调整Image的Type 是Filled的类型。