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).

YarnTaskCompletionSource

Provides a mechanism to create a Yarn Task and set it as completed or cancelled from a non-async environment.
public class YarnTaskCompletionSource

Inherits from System.Object

The main use of this class is to be able to provide a Yarn Task that can be awaited like any other, but have it's completion set not by having a method that finishes, but by an external factor. Essentially this allows non-async code to create a facade of asynchronicity without changing their underlying implementation significantly.

Used in many different places one of the main uses of this is to allow the Unity UI and Input systems to use a callback to set an option as selected as they expect. These callbacks then use this class to make and complete a task that the rest of Yarn Spinner can await like normal. This allows the Dialogue Presenter to think as everything as being async and allows the UI to think in terms of callbacks, each gets to work how they prefer.

This is the Yarn Task form of the Task/Awaitable/UniTask TaskCompletionSource classes. Similar to YarnTask itself we recommend that where possible you use your underlying awaiter infrastructures equivalents of this class in preference to this class.

See also

#Properties

#Task

public YarnTask Task { get }

Type YarnTask

#Methods

#TrySetCanceled()

public partial bool TrySetCanceled();

Returns Boolean

#TrySetException(System.Exception)

public partial bool TrySetException(System.Exception exception);

Parameters

  • exceptionException

Returns Boolean

#TrySetResult()

public partial bool TrySetResult();

Returns Boolean

Generated from Yarn Spinner for Unity 3.3.