Actions
public class Actions : IActionRegistrationInherits from System.Object
Implements Yarn.Unity.IActionRegistration
#Methods
#ActionFromMethodInfo(MethodInfo, string, ActionType)
public static Yarn.Shared.Action ActionFromMethodInfo(MethodInfo method, string yarnName, ActionType actionType)Parameters
methodMethodInfoThe method itseldyarnNamestringthe yarn name of the methodactionTypeActionTypeThe 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)
public void AddCommandHandler(string commandName, Delegate handler)Parameters
commandNamestringThe name of the command.handlerDelegateTheCommandHandlerthat 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)
public void AddCommandHandler(string commandName, MethodInfo methodInfo)Parameters
commandNamestringThe name of the command.handler(unknown)TheCommandHandlerthat will be invoked when the command is called.commandName(unknown)The name of the command.methodInfoMethodInfoThe 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)
public void AddFunction(string name, Delegate implementation)Parameters
namestringThe name of the function to add.implementationDelegateTheSystem.Delegatethat 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)
public void RemoveCommandHandler(string commandName)Parameters
commandNamestringThe name of the command to remove.
#RemoveFunction(string)
public void RemoveFunction(string name)Parameters
namestringThe 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.