All pages
Powered by GitBook
1 of 36

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

Loading...

autoStart

Field in

Whether the dialogue runner will immediately start running dialogue after loading.

public bool autoStart = false;

Summary

DialogueRunner

DialogueRunner

Class in Yarn.Unity

Inherits from UnityEngine.MonoBehaviour

Summary

public class DialogueRunner : IActionRegistration

Fields

Name
Description

Whether the dialogue runner will immediately start running dialogue after loading.

Name
Description
Name
Description

A Unity event that is called once the dialogue has completed.

A Unity event that is called when the dialogue starts running.

A Unity event that is called when a node is complete.

A Unity event that is called when a node starts running.

A that is called when a is received and no command handler was able to handle it.

If this value is set, when an option is selected, the line contained in it ( ) will be delivered to the dialogue runner's dialogue presenters as though it had been written as a separate line.

The name of the node that will start running immediately after loading.

If true, will print Debug.Log messages every time it enters a node, and other frequent events.

Adds a command handler. Dialogue will pause execution after the command is called.

Adds a command handler. Dialogue will pause execution after the command is called.

Gets the internal object that reads and executes the Yarn script.

Gets or sets the collection of dialogue presenters attached to this dialogue runner.

Methods

Properties

autoStart

Add a new function that returns a value, so that it can be called from Yarn scripts.

Loads all variables from the requested file in persistent storage into the Dialogue Runner's variable storage.

Removes a command handler.

Remove a registered function.

Requests that all dialogue presenters speed up their delivery of the current line.

Requests that all dialogue presenters stop showing the current line, and prepare to show the next piece of content.

Saves all variables from variable storage into the persistent storage.

Sets the dialogue runner's Yarn Project.

Splits input into a number of non-empty sub-strings, separated by whitespace, and grouping double-quoted strings into a single sub-string.

Starts running a node of dialogue.

Stops the dialogue immediately, and cancels any currently running dialogue presenters.

Gets a that completes when the dialogue runner finishes its dialogue.

Gets or sets the collection of dialogue presenters attached to this dialogue runner.

Gets a value that indicates if the dialogue is actively running.

Gets the that this dialogue runner uses to fetch localized line content.

Gets the VariableStorage that this dialogue runner uses to store and access Yarn variables.

Gets the asset that this dialogue runner uses.

onDialogueComplete
onDialogueStart
onNodeComplete
onNodeStart
onUnhandledCommand
UnityEventString
Command
runSelectedOptionAsLine
Line
startNode
verboseLogging
AddCommandHandler(string,Delegate)
AddCommandHandler(string,MethodInfo)
AddFunction(string,Delegate)
Dialogue
Dialogue
DialoguePresenters
DialogueTask
FindRunner(Component)
LoadStateFromPersistentStorage(string)
RegisterFunctionDeclaration(string,Type,Type[])
RemoveCommandHandler(string)
RemoveFunction(string)
RequestHurryUpLine()
RequestHurryUpOption()
RequestNextLine()
SaveStateToPersistentStorage(string)
SetProject(YarnProject)
SplitCommandText(string)
StartDialogue(string)
Stop()
YarnTask
DialogueViews
IsDialogueRunning
IsInPlaymode
LineProvider
ILineProvider
NoOptionSelected
VariableStorage
YarnProject
YarnProject

Stop()

Method in DialogueRunner

Summary

Stops the dialogue immediately, and cancels any currently running dialogue presenters.

public async YarnTask Stop()

AddCommandHandler(string,MethodInfo)

Method in DialogueRunner

Summary

Adds a command handler. Dialogue will pause execution after the command is called.

public void AddCommandHandler(string commandName, MethodInfo method);

Remarks

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

Parameters

Name
Description

SaveStateToPersistentStorage(string)

Method in DialogueRunner

Summary

Saves all variables from variable storage into the persistent storage.

public bool SaveStateToPersistentStorage(string saveFileName)

Remarks

This method attempts to writes the contents of VariableStorage as a JSON file and saves it to the persistent data storage under the file name saveFileName. The saved information can be loaded via the LoadStateFromPersistentStorage(string) method.

If saveFileName already exists, it will be overwritten, not appended.

Parameters

Name
Description

true if the variables were successfully written into the player preferences; false otherwise.

RegisterFunctionDeclaration(string,Type,Type[])

Method in DialogueRunner

Summary

public void RegisterFunctionDeclaration(string name, Type returnType, Type[] parameterTypes)

Parameters

Name
Description

string name

Type returnType

AddCommandHandler(string,Delegate)

Method in

Adds a command handler. Dialogue will pause execution after the command is called.

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

If handler is a method that returns a UnityEngine.Coroutine, when the command is run, the 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 will start a coroutine using that method and wait for that coroutine to stop before delivering any more content.

SetProject(YarnProject)

Method in

Sets the dialogue runner's Yarn Project.

If the dialogue runner is currently running (that is, is true ), an System.InvalidOperationException is thrown.

Name
Description

IsDialogueRunning

Property in

Gets a value that indicates if the dialogue is actively running.

LineProvider

Property in

Gets the that this dialogue runner uses to fetch localized line content.

Type[] parameterTypes

string saveFileName

the name the save file should have on disc, including any file extension

Returns

public bool IsDialogueRunning { get }

Summary

DialogueRunner
public ILineProvider LineProvider { get; }

Summary

DialogueRunner
ILineProvider

string commandName

The name of the command.

handler

The that will be invoked when the command is called.

commandName

The name of the command.

Name
Description
public void AddCommandHandler(string commandName, Delegate handler);
<<commandName param1 param2>>

Summary

Remarks

Parameters

DialogueRunner
DialogueRunner
DialogueRunner
public void SetProject(YarnProject project)

Summary

Remarks

Parameters

DialogueRunner
IsDialogueRunning

RemoveCommandHandler(string)

Method in

Removes a command handler.

Name
Description

methodInfo

The method that will be invoked when the command is called.

MethodInfo method

CommandHandler
public void RemoveCommandHandler(string commandName);

string commandName

The name of the command to remove.

Summary

Parameters

DialogueRunner

string commandName

The name of the command.

Delegate handler

The that will be invoked when the command is called.

project

The new to be used.

CommandHandler
Yarn.Unity.YarnProject
YarnProject

DialogueViews

Property in

Gets or sets the collection of dialogue presenters attached to this dialogue runner.

This property is deprecated. Use instead.

public IEnumerable<DialoguePresenterBase?> DialogueViews { get; set; }

This property is obsolete and may be removed from a future version of Yarn Spinner: Use DialoguePresenters.

Summary

Remarks

DialogueRunner
DialoguePresenters

runSelectedOptionAsLine

Field in

If this value is set, when an option is selected, the line contained in it ( ) will be delivered to the dialogue runner's dialogue presenters as though it had been written as a separate line.

This allows a Yarn script to

public bool runSelectedOptionAsLine = false;

Summary

Remarks

DialogueRunner
Line

onDialogueComplete

Field in

A Unity event that is called once the dialogue has completed.

  • : Gets or sets the that is called when the dialogue reaches its end.

public UnityEvent? onDialogueComplete;

Summary

See Also

DialogueRunner
Dialogue.DialogueCompleteHandler
DialogueCompleteHandler

onUnhandledCommand

Field in DialogueRunner

Summary

A UnityEventString that is called when a Command is received and no command handler was able to handle it.

public UnityEventString? onUnhandledCommand;

Remarks

Use this method to dispatch a command to other parts of your game. This method is only called if the Command has not been handled by a command handler that has been added to the DialogueRunner, or by a method on a UnityEngine.MonoBehaviour in the scene with the attribute YarnCommandAttribute.

When a command is delivered in this way, the will not pause execution. If you want a command to make the DialogueRunner pause execution, see .

This method receives the full text of the command, as it appears between the << and >> markers.

See Also

  • : Adds a command handler. Dialogue will pause execution after the command is called.

  • : An attribute that marks a method on an object as a command.

DialogueRunner.AddCommandHandler(string,Delegate)
YarnCommandAttribute
DialogueRunner
AddCommandHandler(string,Delegate)

onDialogueStart

Field in

A Unity event that is called when the dialogue starts running.

public UnityEvent? onDialogueStart;

Summary

DialogueRunner

verboseLogging

Field in DialogueRunner

Summary

If true, will print Debug.Log messages every time it enters a node, and other frequent events.

public bool verboseLogging = false;

RequestHurryUpLine()

Method in DialogueRunner

Summary

Requests that all dialogue presenters speed up their delivery of the current line.

public void RequestHurryUpLine()

Remarks

The specific behaviour of what happens when this method is called depends on the implementation of the Dialogue Runner's current dialogue presenters.

If the dialogue runner is not currently running a line (for example, if it is running options, or is not running dialogue at all), this method has no effect.

SplitCommandText(string)

Method in DialogueRunner

Summary

Splits input into a number of non-empty sub-strings, separated by whitespace, and grouping double-quoted strings into a single sub-string.

public static IEnumerable<string> SplitCommandText(string input)

Remarks

This method behaves similarly to the System.String.Split(System.Char[],System.StringSplitOptions) method with the System.StringSplitOptions parameter set to System.StringSplitOptions.RemoveEmptyEntries , with the following differences:

  • Text that appears inside a pair of double-quote characters will not be split.

  • Text that appears after a double-quote character and before the end of the input will not be split (that is, an unterminated double-quoted string will be treated as though it had been terminated at the end of the input.)

  • When inside a pair of double-quote characters, the string \\ will be converted to \, and the string \" will be converted to ".

Name
Description

A collection of sub-strings.

AddFunction(string,Delegate)

Method in

Add a new function that returns a value, so that it can be called from Yarn scripts.

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

The call command can also be used to invoke the function:

Name
Description

string input

The string to split.

Parameters

Returns

  • : A collection of functions that can be called from Yarn programs.

public void AddFunction(string name, Delegate implementation);
<<if myFunction(1, 2) == true>>
myFunction returned true!
<<endif>>
<<call myFunction(1, 2)>>

Summary

Remarks

Parameters

DialogueRunner

string name

The name of the function to add.

Delegate implementation

The System.Delegate that should be invoked when this function is called.

See Also

Library

startNode

Field in

The name of the node that will start running immediately after loading.

This value must be the name of a node present in .

  • : Gets the asset that this dialogue runner uses.

  • : Starts running a node of dialogue.

Summary

Remarks

See Also

DialogueRunner
YarnProject
DialogueRunner.YarnProject
YarnProject
DialogueRunner.StartDialogue(string)
public string startNode = "Start";

onNodeComplete

Field in

A Unity event that is called when a node is complete.

This event receives as a parameter the name of the node that just finished running.

  • : Gets or sets the that is called when a node is complete.

Summary

Remarks

See Also

DialogueRunner
Dialogue.NodeCompleteHandler
NodeCompleteHandler
public UnityEventString? onNodeComplete;

StartDialogue(string)

Method in DialogueRunner

Summary

Starts running a node of dialogue.

public async YarnTask StartDialogue(string nodeName)

Remarks

nodeName must be the name of a node in YarnProject .

Parameters

Name
Description

string nodeName

The name of the node to run.

onNodeStart

Field in

A Unity event that is called when a node starts running.

This event receives as a parameter the name of the node that is about to start running.

  • : Gets or sets the that is called when a node is started.

Summary

Remarks

See Also

DialogueRunner
Dialogue.NodeStartHandler
NodeStartHandler
public UnityEventString? onNodeStart;

RemoveFunction(string)

Method in DialogueRunner

Summary

Remove a registered function.

public void RemoveFunction(string name);

Remarks

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

Parameters

Name
Description

string name

The name of the function to remove.

See Also

  • : Add a new function that returns a value, so that it can be called from Yarn scripts.

IActionRegistration.AddFunction(string,Delegate)

DialogueTask

Property in

Gets a that completes when the dialogue runner finishes its dialogue.

If the dialogue is not currently running when this property is accessed, the property returns a task that is already complete.

public YarnTask DialogueTask { get; }

Summary

Remarks

DialogueRunner
YarnTask

DialoguePresenters

Property in

Gets or sets the collection of dialogue presenters attached to this dialogue runner.

public IEnumerable<DialoguePresenterBase?> DialoguePresenters { get; set; }

Summary

DialogueRunner

YarnProject

Property in

Gets the asset that this dialogue runner uses.

  • : Sets the dialogue runner's Yarn Project.

public YarnProject? YarnProject { get }

Summary

See Also

DialogueRunner
YarnProject
DialogueRunner.SetProject(YarnProject)

LoadStateFromPersistentStorage(string)

Method in DialogueRunner

Summary

Loads all variables from the requested file in persistent storage into the Dialogue Runner's variable storage.

public bool LoadStateFromPersistentStorage(string saveFileName)

Remarks

This method loads the file saveFileName from the persistent data storage and attempts to read it as JSON. This is then deserialised and loaded into the VariableStorage.

The loaded information can be stored via the SaveStateToPersistentStorage(string) method.

Parameters

Name
Description

true if the variables were successfully loaded from the player preferences; false otherwise.

string saveFileName

the name the save file should have on disc, including any file extension

Returns

FindRunner(Component)

Method in

Name
Description
public static DialogueRunner? FindRunner(Component component)

Component component

Summary

Parameters

DialogueRunner

IsInPlaymode

Property in

public static bool IsInPlaymode { get; }

Summary

DialogueRunner

RequestNextLine()

Method in

Requests that all dialogue presenters stop showing the current line, and prepare to show the next piece of content.

The specific behaviour of what happens when this method is called depends on the implementation of the Dialogue Runner's current dialogue presenters.

If the dialogue runner is not currently running a line (for example, if it is running options, or is not running dialogue at all), this method has no effect.

public void RequestNextLine()

Summary

Remarks

DialogueRunner

VariableStorage

Property in

Gets the VariableStorage that this dialogue runner uses to store and access Yarn variables.

public VariableStorageBehaviour VariableStorage { get; set; }

Summary

DialogueRunner

Dialogue

Property in

Gets the internal object that reads and executes the Yarn script.

public Dialogue Dialogue { get; }

Summary

DialogueRunner
Dialogue

NoOptionSelected

Property in

public static YarnTask<DialogueOption?> NoOptionSelected { get; }

Summary

DialogueRunner

RequestHurryUpOption()

Method in

public void RequestHurryUpOption()

Summary

DialogueRunner