LoginSignup
0
0

More than 3 years have passed since last update.

【カウントダウン】何秒経ったらゲーム終了と表示する【テンプレスクリプト】

Posted at

下記スクリプトがアタッチされたオブジェクトは、
fltTimeCountで指定された分だけカウントダウンを行い、
ゼロになったら「ゲーム終了」とされます。

CountDown.cs
using UnityEngine;
using UnityEngine.UI;
public class CountDown : MonoBehaviour
{
    public float fltTimeCount;
    public Text txtCountDown;
    void Update()
    {
        fltTimeCount -= Time.deltaTime;
        txtCountDown.text = fltTimeCount.ToString("f0");
        if (fltTimeCount <= 0) txtCountDown.text = "ゲーム終了";
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0