Skip to content

Task Extensions

Andrzej Kebab edited this page Feb 4, 2024 · 1 revision

UtilityLibrary.Core

AsCoroutine

Converts the Task into an IEnumerator for Unity coroutine usage.

Task myTask = // initialize your Task
IEnumerator coroutine = myTask.AsCoroutine();

Parameters:

  • task: The Task to convert.

Returns:

  • coroutine: An IEnumerator representation of the Task.

Usage:

async void MyMethod()
{
    Task myTask = SomeAsyncMethod();
    yield return myTask.AsCoroutine();
    // Continue with the rest of the coroutine logic...
}

Note:

Clone this wiki locally