赞
踩
async a(){
let p = new Promise((resolve,reject) => {
setTimeout(resolve,1000,3);
})
console.log(await p);//3
}
相当于Unity的yield return new WaitForSeconds(1);
using Cysharp.Threading.Tasks;
public class Demo{
async UniTask<string> demoAsync(){
var t = await Resources.LoasAsync<TextAsset>("foo");
await UniTask.Delay(TimeSpan.FromSeconds(10),
ignoreTimeScale:false);
return t?.text ?? throw InvalidOperationException("None");
}
}
C#新特性,运算符
?.
指当前者不为空时取得.
之后的属性。??
判空。但这两个运算符不要用在对"物体身上某组件是否为空“的判断上。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。