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

Actions

The "default" action registration system used
public class Actions : IActionRegistration

Inherits from System.Object

Implements Yarn.Unity.IActionRegistration

#Methods

#ActionFromMethodInfo(MethodInfo, string, ActionType)

Given a methodinfo collected via reflection converts into a T:Yarn.Shared.Action
public static Yarn.Shared.Action ActionFromMethodInfo(MethodInfo method, string yarnName, ActionType actionType)

Parameters

  • methodMethodInfo
    The method itseld
  • yarnNamestring
    the yarn name of the method
  • actionTypeActionType
    The type of the action, so is it a command or a function?

Returns Action: The action. If something went wrong will be an T:Yarn.Shared.InvalidAction instead.

#AddCommandHandler(string, Delegate)

Adds a command handler and registers the command with Yarn as one that can be called.
public void AddCommandHandler(string commandName, Delegate handler)

Parameters

  • commandNamestring
    The name of the command.
  • handlerDelegate
    The CommandHandler that will be invoked when the command is called.

You can also register commands via the YarnCommandAttribute attribute on your methods.

When this command handler has been added, it can be called from your Yarn scripts like so:

     <<commandName param1 param2>>
     

If handler is a method that returns a YarnTask, Task, Awaitable, or UniTask when the command is run, the DialogueRunner will wait for the task to finish before delivering any more content.

If handler is a method that returns a Coroutine, when the command is run, the DialogueRunner will wait for the returned coroutine to stop before delivering any more content.

If handler is a method that returns an System.Collections.IEnumerator, when the command is run, the DialogueRunner will start a coroutine using that method and wait for that coroutine to stop before delivering any more content.

#AddCommandHandler(string, MethodInfo)

Adds a command handler and registers the command with Yarn as one that can be called.
public void AddCommandHandler(string commandName, MethodInfo methodInfo)

Parameters

  • commandNamestring
    The name of the command.
  • handler(unknown)
    The CommandHandler that will be invoked when the command is called.
  • commandName(unknown)
    The name of the command.
  • methodInfoMethodInfo
    The method that will be invoked when the command is called.

You can also register commands via the YarnCommandAttribute attribute on your methods.

When this command handler has been added, it can be called from your Yarn scripts like so:

     <<commandName param1 param2>>
     

If handler is a method that returns a YarnTask, Task, Awaitable, or UniTask when the command is run, the DialogueRunner will wait for the task to finish before delivering any more content.

If handler is a method that returns a Coroutine, when the command is run, the DialogueRunner will wait for the returned coroutine to stop before delivering any more content.

If handler is a method that returns an System.Collections.IEnumerator, when the command is run, the DialogueRunner will start a coroutine using that method and wait for that coroutine to stop before delivering any more content.

#AddFunction(string, Delegate)

Add a new function that returns a value, so that it can be called from Yarn scripts.
public void AddFunction(string name, Delegate implementation)

Parameters

  • namestring
    The name of the function to add.
  • implementationDelegate
    The System.Delegate that should be invoked when this function is called.

You can also register functions via the YarnFunctionAttribute attribute on your methods.

When this function has been registered, it can be called from your Yarn scripts like so:

     <<if myFunction(1, 2) == true>>
         myFunction returned true!
     <<endif>>
     

See also

  • Library

#RemoveCommandHandler(string)

Removes a command handler. This does not impact the compiled Yarn program, only the runtime actions. The Yarn VM will still attempt to call the command when it encounters it, likely results in an exception being thrown. In general you should only remove commands if you know they won't be needed.
public void RemoveCommandHandler(string commandName)

Parameters

  • commandNamestring
    The name of the command to remove.

#RemoveFunction(string)

Remove a registered function.
public void RemoveFunction(string name)

Parameters

  • namestring
    The name of the function to remove.

After a function has been removed, it cannot be called from Yarn scripts.

This does not impact the compiled Yarn program, only the runtime actions. The Yarn VM will still attempt to call the function when it encounters it, likely resulting in an exception being thrown. In general you should only remove functions if you know they won't be needed.

See also

Generated from Yarn Spinner for Unity 3.3.