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<T>

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<T>

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.

#Methods

#Forget()

readonly public void Forget()

#FromResult(T)

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

Parameters

  • valueT

Returns YarnTask

#GetAwaiter()

public TaskAwaiter<T> GetAwaiter();

Returns TaskAwaiter

#IsCompleted()

readonly public bool IsCompleted();

Returns Boolean

#IsCompletedSuccessfully()

readonly public bool IsCompletedSuccessfully();

Returns Boolean

Generated from Yarn Spinner for Unity 3.3.