我真的很想知道是否有辦法定義動作變數async?或者一些替代方法?
public System.Action myAction;
public async System.Action myAsyncAction;
void Start()
{
// normal action
myAction = () =>
{
Debug.Log("Inject some code in runtime..");
};
// I want something like this that support wait time..
myAsyncAction = () =>
{
await Task.Delay(2000f);
Debug.Log("Inject some code in runtime..");
};
}
uj5u.com熱心網友回復:
我過去用過Func<Task>。例如:
Func<Task> asyncMethod = async () =>
{
await Task.Delay(1000);
Console.WriteLine("done here");
};
await asyncMethod();
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/470911.html
