赞
踩
- // extension awaiter/methods can be used by this namespace
- using Cysharp.Threading.Tasks;
-
- // You can return type as struct UniTask<T>(or UniTask), it is unity specialized lightweight alternative of Task<T>
- // zero allocation and fast excution for zero overhead async/await integrate with Unity
- async UniTask<string> DemoAsync()
- {
- // You can await Unity's AsyncObject
- var asset = await Resources.LoadAsync<TextAsset>("foo");
- var txt = (await UnityWebRequest.Get("https://...").SendWebRequest()).downloadHandler.text;
- await SceneManager.LoadSceneAsync("scene2");
-
- // .WithCancellation enables Cancel, GetCancellationTokenOnDestroy synchornizes with lifetime of GameObject
- var asset2 = await Resources.LoadAsync<TextAsset>("bar").WithCancellation(this.GetCancellationTokenOnDestroy());
-
- // .ToUniTask accepts progress callback(and all opti
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。