【Unity】経過時間とカウントダウン
経過時間とカウントダウン
using System; using UnityEngine; using System.Collections; public class GameManager : MonoBehaviour { private DateTime _startTime; private readonly int _limitTime = 10; void Start () { this._startTime = DateTime.Now; } void Update () { TimeSpan pastTime = DateTime.Now -this._startTime; // カウントダウン機能 var countDown = this._limitTime - pastTime.Seconds; print (countDown); } }
「readonly」って何?「const」と同じらしい。