Reactive Extensions forUnityhttps://github.com/neuecc/UniRx/async/await(UniTask)async UniTask<string> DemoAsync(){// You can await Unity's AsyncObjectvar asset = await Resources.LoadAsync<TextAsset>("foo");// .ConfigureAwait accepts progress callbackawait SceneManager.LoadSceneAsync("scene2").ConfigureAwai// await frame-based operation(you can also await frame cawait UniTask.Delay(TimeSpan.FromSeconds(3));// like 'yield return WaitForEndOfFrame', or Rx's Observeawait UniTask.Yield(PlayerLoopTiming.PostLateUpdate);// You can await standard taskawait Task.Run(() => 100);// get async webrequestasync UniTask<string> GetTextAsync(UnityWebRequest req){var op = await req.SendWebRequest();return op.downloadHandler.text;}var task1 = GetTextAsync(UnityWebRequest.Get("http://googvar task2 = GetTextAsync(UnityWebRequest.Get("http://bingvar task3 = GetTextAsync(UnityWebRequest.Get("http://yaho// concurrent async-wait and get result easily by tuple svar (google, bing, yahoo) = await UniTask.WhenAll(task1,// You can handle timeout easilyawait GetTextAsync(UnityWebRequest.Get("http://unity.com"
ラムダ式のキャプチャstatic void Run(List<int>list, string format){// ラムダ式のキャプチャ(外側の変数を中で使うこと)は暗黙的なクラス生成が入る// 以下のようなコードが生成されるので、クラスとデリゲートの二つがアロケート対象。// var capture = new { format };// new Action<int>(capture.Run);list.ForEach(x =>{Console.WriteLine(string.Format(format, x));});}
79.
ラムダ式のキャプチャstatic void Run(List<int>list, string format){// ラムダ式のキャプチャ(外側の変数を中で使うこと)は暗黙的なクラス生成が入る// 以下のようなコードが生成されるので、クラスとデリゲートの二つがアロケート対象。// var capture = new { format };// new Action<int>(capture.Run);list.ForEach(x =>{Console.WriteLine(string.Format(format, x));});}
80.
static void Run(List<int>list, string format, bool cond){// does not use lambda, but...if (cond){Console.WriteLine("Do Nothing");return;}// use capture pathlist.ForEach(x =>{Console.WriteLine(string.Format(format, x));});}
81.
static void Run(List<int>list, string format, bool cond){// does not use lambda, but...if (cond){Console.WriteLine("Do Nothing");return;}// use capture pathlist.ForEach(x =>{Console.WriteLine(string.Format(format, x));});}