Skip to content

Instantly share code, notes, and snippets.

@Sythelux
Created August 5, 2020 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sythelux/4f0d97ea68318d21766ade48667ccb05 to your computer and use it in GitHub Desktop.
Save Sythelux/4f0d97ea68318d21766ade48667ccb05 to your computer and use it in GitHub Desktop.
A CustomYieldInstruction for Unity that just wraps waiting on a task.
///<author email="dersyth@gmail.com">Sythelux Rikd</author>
public class WaitOnTask : CustomYieldInstruction
{
private Task _task;
private bool _taskDone;
public override bool keepWaiting => !_taskDone;
public WaitOnTask(Task task)
{
_task = task;
task.ContinueWith(_ => _taskDone = true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment