Pardon our dust! Docs for Yarn Spinner for Unity 3.2 and Yarn Spinner for Godot C# are on docs.yarnspinner.dev (the old docs site). Docs for Yarn Spinner for Unity 3.3 (pre-release, out ASAP), Yarn Spinner for Godot GDScript and Yarn Spinner for Unreal Engine (work in progress) are on /docs/ (the new docs site).

YarnTask

Yarn Task is a convenience Awaiter that acts as a wrapper type around the underlying Awaiter that your Unity project is using.
public partial struct YarnTask

Inherits from System.ValueType

In Unity there are many different possible Awaiter types you could be making use of. Depending on your Unity set up the Yarn Task will wrap and forward any async behaviour into:

  1. Cysharp.Threading.Tasks.UniTask
  2. UnityEngine.Awaitable
  3. System.Threading.Tasks.Task
These are listed in the order of priority for the underlying awaiter, the upshot being UniTask is chosen over Awaitable over Task.

In general we recommend that you use the underlying awaiter instead of Yarn Task. Yarn Task exists primarily so that we don't have to wrap all our code and samples inside ifdefs and usings. As such it has only the minimum features needed to play the role of forwarding async calls. There are many quality of life features that the underlying awaiters have that we've not implemented because we don't need them for this job.

#Properties

#CompletedTask

public static YarnTask CompletedTask { get }

Type YarnTask

#Methods

#Delay(int, CancellationToken)

Creates a YarnTask that delays for the time indicated by timeSpan, and then returns.
public static YarnTask Delay(int milliseconds, CancellationToken token = default);

Parameters

  • timeSpan(unknown)
    The amount of time to wait.
  • tokenCancellationToken
    A token that can be used to cancel the task.
  • millisecondsint
    The amount of time to wait.

Returns YarnTask: A new YarnTask.

#Delay(TimeSpan, CancellationToken)

Creates a YarnTask that delays for the time indicated by timeSpan, and then returns.
public static partial YarnTask Delay(TimeSpan timeSpan, CancellationToken token = default);

Parameters

  • timeSpanTimeSpan
    The amount of time to wait.
  • tokenCancellationToken
    A token that can be used to cancel the task.

Returns YarnTask: A new YarnTask.

#Forget()

readonly public async void Forget()

#FromResult<T>(T)

public static YarnTask<T> FromResult<T>(T value);

Parameters

  • valueT

Returns YarnTask

#GetAwaiter()

public TaskAwaiter GetAwaiter();

Returns TaskAwaiter

#IsCompleted()

readonly public bool IsCompleted();

Returns Boolean

#IsCompletedSuccessfully()

readonly public bool IsCompletedSuccessfully();

Returns Boolean

#SuppressCancellationThrow()

public readonly partial YarnTask<bool> SuppressCancellationThrow();

Returns YarnTask

#ToCoroutine(Func<YarnTask>)

public static partial IEnumerator ToCoroutine(Func<YarnTask> factory);

Parameters

  • factoryFunc<Yarn.Unity.YarnTask>

Returns IEnumerator

#WaitForAsyncOperation(AsyncOperationHandle, CancellationToken)

public static partial YarnTask WaitForAsyncOperation(AsyncOperationHandle operationHandle, CancellationToken cancellationToken);

Parameters

  • operationHandleAsyncOperationHandle
  • cancellationTokenCancellationToken

Returns YarnTask

#WaitForAsyncOperation<T>(AsyncOperationHandle<T>, CancellationToken)

public static partial YarnTask<T> WaitForAsyncOperation<T>(AsyncOperationHandle<T> operationHandle, CancellationToken cancellationToken);

Parameters

  • operationHandleAsyncOperationHandle<T>
  • cancellationTokenCancellationToken

Returns YarnTask

#WaitUntil(System.Func<bool>, System.Threading.CancellationToken)

public static partial YarnTask WaitUntil(System.Func<bool> predicate, System.Threading.CancellationToken token = default);

Parameters

  • predicateFunc<bool>
  • tokenCancellationToken

Returns YarnTask

#WaitUntilCanceled(System.Threading.CancellationToken)

public static partial YarnTask WaitUntilCanceled(System.Threading.CancellationToken token);

Parameters

  • tokenCancellationToken

Returns YarnTask

#WhenAll(IEnumerable<YarnTask>)

public static partial YarnTask WhenAll(IEnumerable<YarnTask> tasks);

Parameters

  • tasksIEnumerable<Yarn.Unity.YarnTask>

Returns YarnTask

#WhenAll(YarnTask[])

public static partial YarnTask WhenAll(params YarnTask[] tasks);

Parameters

Returns YarnTask

#WhenAll<T>(IEnumerable<YarnTask<T>>)

public static partial YarnTask<T[]> WhenAll<T>(IEnumerable<YarnTask<T>> tasks);

Parameters

  • tasksIEnumerable<Yarn.Unity.YarnTask<T>>

Returns YarnTask

#WhenAll<T>(YarnTask<T>[])

public static partial YarnTask<T[]> WhenAll<T>(params YarnTask<T>[] tasks);

Parameters

  • tasksYarn.Unity.YarnTask<T>[]

Returns YarnTask

#Yield()

public static partial YarnTask Yield();

Returns YarnTask

Generated from Yarn Spinner for Unity 3.3.