Yarn Projects
Learn about Yarn Projects, which group your scripts together for use in a Dialogue Runner.
A Yarn Project is a file that links multiple Yarn scripts together. Yarn projects are how Dialogue Runners work with your content.
Creating a New Yarn Project
To create a new Yarn Project, follow these steps:
Open the Assets menu, and choose Yarn Spinner -> Yarn Project.
Unity will create a new file. Type in a name for the file, and press return.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-2f73b2c1307d305f55dc96170a89abd202315547%252Fyarn-spinner-unity-creating-yarn-project.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=91dcf1d3&sv=1)
This new Yarn Project will be empty, and won't contain any references to other Yarn scripts yet.
Adding Yarn scripts to a Yarn Project
On their own, a Yarn Project doesn't do anything. In order to be useful, you need to add Yarn scripts to it.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-4b1da667a1bc429b6db8a3d1e80a7aa1661204c8%252Fyarn-spinner-unity-empty-project.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=d33a2b62&sv=1)
To add Yarn scripts to a Yarn Project, follow these steps:
Select the Yarn Project in the Project Pane.
In the Inspector, open the Source Scripts property at the top of the pane.
Drag the Yarn script you want to add into the Source Scripts list.
Click Apply at the bottom of the pane.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-038b35aa79ab42352ced1a276f9316568520f961%252Fyarn-project-adding-scripts.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=e9940625&sv=1)
Creating a Project from a Script
As an alternative to creating an empty project and adding scripts to it, you can create a new Yarn Project from a script. To do this, follow these steps:
Select the Yarn script in the Project pane.
In the Inspector, click the Create New Yarn Project button.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-c57080037b78be8e0bcbcad7fe18d1f88cd50aaf%252Fyarn-spinner-unity-create-new-project-button.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=fdbf38e0&sv=1)
Clicking this button does two things:
A new Yarn Project will be created next to the Yarn script.
The new Yarn Project will be set up to include the Yarn script you created it from in its list of source scripts.
Managing Variables
A Yarn Project's inspector shows information about every variable that are used in the Yarn scripts. This section of the Inspector shows the name, type, description, and default value of each variable.
This information comes from the following locations:
All variables that have been declared in a Yarn script with a
declare
statementAll variables that have been manually added to this Yarn project
All variables that are used, but don't have a
declare
statement
Declaring a variable in a Yarn script by using a declare
statement, or by manually adding it to the variables list, allows you to ensure that the variable is of the type you expect it to be, and that it has a description that explains the intended purpose of the variable.
If you don't declare a variable, Yarn Spinner will attempt to figure the variable's type out based on how it's used, and won't be able to provide a description.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-efa45ad9ecd5d2edf80f7427b27113230d8dc78b%252Fyarn-project-variables.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=156b41d2&sv=1)
Managing Localisations and Assets
When you write a Yarn script, you write it in a specific human language. This is referred to as the 'base' language of the script. It's called the base language because it's the one you start with, and the one you translate into other languages.
Unless you change it to something else, Yarn Spinner will set the base language to your computer's current locale.
You can set the base language of a Yarn Project in the Inspector by changing the Base Language setting.
![](https://docs.yarnspinner.dev/~gitbook/image?url=https%3A%2F%2F99231152-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FS4mXHmtpu6Jra6GMq89c%252Fuploads%252Fgit-blob-909d5d0f204159e08d1cec08a47062844722d413%252Fdefault-language.png%3Falt%3Dmedia&width=768&dpr=4&quality=100&sign=ac9f1b38&sv=1)
If you want to translate your scripts into another language, or if you want to associate each line with assets (like voice over audio clips), you create a new Localisation. To learn about this process, see Adding Localizations and Assets to Projects.
Using Yarn Projects with Dialogue Runners
Yarn Projects are used by Dialogue Runners. When a Dialogue Runner is told to start running dialogue, it reads it from the Yarn Project it's been provided.
If you try to start a Dialogue Runner and it doesn't have a Yarn Project, or the Yarn Project doesn't have any Yarn scripts, or if any of the Yarn scripts contain an error, the Dialogue Runner won't be able to run.
Inspector
Property | Description |
---|---|
Source Scripts | The list of Yarn Scripts that this Yarn Project uses. |
Declarations | The list of variables that are declared in this Yarn Project, or in the Yarn Scripts that this project uses. |
Base Language | The language that the Yarn Scripts are written in. |
Localisations | A mapping of languages to string tables and associated assets. See Adding Localizations and Assets to Projects for more information. |
Search All Assemblies | If this is turned on, Yarn Spinner will search for custom commands and functions in all of your project's code and packages. If this is turned off, it will only search for them in the default assembly, and in the assemblies specified in Assemblies to Search. By default, this is turned on. |
Assemblies To Search | If Search All Assemblies is turned off, Yarn Spinner will search for commands and actions in the assemblies you specify in this list, as well as the default assembly. This list will only appear if Search All Assemblies is turned off. |
Use Addressable Assets | If this is turned on, the Yarn Project will configure itself to look for assets using the Addressable Assets system. This checkbox will only appear if the Addressable Assets package is installed in your project. |
Update Asset Addresses | When you click this button, all of the assets in the folders specified in the Languages to Source Assets list will have their address updated to match the line ID they refer to. |
Export Strings as CSV | When you click this button, all of the lines in the Yarn Scripts that this project uses will be written to a |
Update Existing Strings Files | When you click this button, all |
Add Line Tags to Scripts | When you click this button, any line of dialogue in the Source Scripts list that doesn't have a |
Last updated