I really want to know if there is a way to define action variables async
? Or some alternative method?
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..");
};
}
CodePudding user response:
I've used Func<Task>
in the past. EG:
Func<Task> asyncAction = async () =>
{
await Task.Delay(1000);
Console.WriteLine("done here");
};
await asyncAction();