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

Project

Yarn Projects represent instructions on where to find Yarn scripts and associated assets, and how they should be compiled.
public class Project

Inherits from System.Object

#Nested Types

  • Stores additional information that describes to the compiler how the project should be compiled.
  • Stores the locations of where localized assets and a localized string table for a Yarn Project may be found.

#Constructors

#Project()

Initializes a new instance of the Project class.
public Project()

#Project(string, string?)

Initializes a new instance of the Project class.
public Project(string path, string? workspaceRootPath = null)

Parameters

  • pathstring
    The value to use for the new instance's Path property.
  • workspaceRootPathstring
    The path to the root of the current workspace, or null.

#Fields

#CurrentProjectFileVersion

The current version of .yarnproject file format.
public const int CurrentProjectFileVersion = YarnSpinnerProjectVersion5;

Type Int32

#WorkspaceRootPlaceholder

A placeholder string that represents the location of the workspace root in paths.
public const string WorkspaceRootPlaceholder = "${workspaceRoot}";

Type String

#YarnSpinnerProjectVersion2

A version number representing project version 2 (released with Yarn Spinner 2.0)
public const int YarnSpinnerProjectVersion2 = 2;

Type Int32

#YarnSpinnerProjectVersion3

A version number representing project version 3 (released with Yarn Spinner 3.0).
public const int YarnSpinnerProjectVersion3 = 3;

Type Int32

#YarnSpinnerProjectVersion4

A version number representing project version 4 (released with Yarn Spinner 3.2.0).
public const int YarnSpinnerProjectVersion4 = 4;

Type Int32

#YarnSpinnerProjectVersion5

A version number representing project version 4 (released with Yarn Spinner 3.3.0).
public const int YarnSpinnerProjectVersion5 = 5;

Type Int32

#Properties

#AllowLanguagePreviewFeatures

Gets or sets a value indicating whether compiler features that are not intended for production use are allowed.
public bool AllowLanguagePreviewFeatures { get; set; }

Type Boolean

#BaseLanguage

Gets or sets the base language of the project, as an IETF BCP-47 language tag.
public string BaseLanguage { get; set; }

Type String

The base language is the language that the Yarn scripts is written in.

#CompilerOptions

Gets or sets an object containing instructions that control how the Yarn Spinner compiler should compile a project.
public CompilerOptionsData CompilerOptions { get; set; }

Type CompilerOptionsData

#Definitions

Gets or sets the patterns for matching paths to JSON files that contain command and function definitions that this project references.
public List<string>? Definitions { get; set; }

Type List

Definitions files are used by editing tools to provide type information and other externally-defined data used by the Yarn scripts.

#DefinitionsFiles

Gets the absolute paths to the project's Definitions files.
public IEnumerable<string> DefinitionsFiles { get; }

Type IEnumerable

#DefinitionsPath Obsolete

Use Definitions

Gets the path to the Definitions file, relative to this project's location.
public string? DefinitionsPath { get; }

Type String

See also

#ExcludeFilePatterns

Gets or sets the collection of file search patterns that should be excluded from this project.
public IEnumerable<string> ExcludeFilePatterns { get; set; }

Type IEnumerable

If a file is matched by a pattern in SourceFilePatterns, and is also matched by a pattern in ExcludeFilePatterns, then it is not included in the value returned by SourceFiles.

#ExtensionData

Contains any data parsed from the source file that was not matched to a property on this type.
public Dictionary<string, JsonElement>? ExtensionData { get; set; }

Type Dictionary

#FileVersion

Gets or sets the file version of the project.
public int FileVersion { get; set; }

Type Int32

This value is required to be equal to CurrentProjectFileVersion.

#Localisation

Gets or sets the collection of LocalizationInfo objects that store information about where localized data for this project is found.
public Dictionary<string, LocalizationInfo> Localisation { get; set; }

Type Dictionary

#Path

Gets the path that the Project was loaded from.
public string? Path { get; set; }

Type String

This value is not stored when the file is saved, but is instead determined when the file is loaded by LoadFromFile(string,string?), or provided when the Project is constructed.

#SourceFilePatterns

Gets or sets the collection of file search patterns used to locate Yarn files that form this project.
public IEnumerable<string> SourceFilePatterns { get; set; }

Type IEnumerable

#SourceFiles

Gets the collection of Yarn files that should be used to compile the project.
public IEnumerable<string> SourceFiles { get; }

Type IEnumerable

This collection uses a Yarn.Compiler.Project.Matcher to find all files specified by SourceFilePatterns, excluding those that are specified by ExcludeFilePatterns.

#WorkspaceRootPath

The location of the root of the workspace in which this project is located.
public string? WorkspaceRootPath { get; set; }

Type String

#Methods

#GetJson()

Gets a string containing JSON-formatted text that represents this Project.
public string GetJson();

Returns String: The Project, serialized to JSON.

#IsMatchingPath(string)

Gets a value indicating whether path is a path that is included in this project.
public bool IsMatchingPath(string path)

Parameters

  • pathstring
    The path to check.

Returns Boolean: true if path is a path that is included in this project; false otherwise.

#IsValidVersionNumber(int)

Gets a value indicating whether number is a valid Yarn Spinner version number.
public static bool IsValidVersionNumber(int number)

Parameters

  • numberint

Returns Boolean

#LoadFromFile(string, string?)

Loads and parses a Project from a file on disk.
public static Project LoadFromFile(string path, string? workspaceRoot = null)

Parameters

  • pathstring
    The path to the file to load.
  • workspaceRootstring
    The path of the root of the workspace in which file is located.

Returns Project: The loaded Project.

Exceptions

  • System.ArgumentException
    Thrown when the contents of the file cannot be loaded.

#SaveToFile(string)

Saves a Project as JSON-formatted text to a file on disk.
public void SaveToFile(string path);

Parameters

  • pathstring
    The path of the file to write to.

Generated from Yarn Spinner for Unity 3.3.