facebook twitter hatena line email

Unity/Csharp/時間

提供: 初心者エンジニアの簡易メモ
移動: 案内検索

サンプル

void Start() {
    System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
    sw.Start();
}
void Update() {
    Debug.Log(sw.ElapsedMilliseconds + "ms")
}
void End() {
    sw.Stop();
    Debug.Log(sw.ElapsedMilliseconds + "ms")
}

https://qiita.com/raku-lab/items/62faa5e6f9d3f060f37e

0に戻して止める場合

sw.Reset();

0に戻して再スタートする場合

sw.Restart();