概要
using System.Diagnostics; using System.Threading.Tasks; using UnityEngine; public class Example : MonoBehaviour { private async void Start() { var sw = new Stopwatch(); sw.Start(); await Task.Delay( 1000 ); sw.Stop(); print( sw.Elapsed.TotalSeconds ); } }
今までこう書いていたけど
using System.Diagnostics; using System.Threading.Tasks; using UnityEngine; public class Example : MonoBehaviour { private async void Start() { var sw = Stopwatch.StartNew(); // ★ await Task.Delay( 1000 ); sw.Stop(); print( sw.Elapsed.TotalSeconds ); } }
こう書ける