Learn about Yarn Projects, which group your scripts together for use in a Dialogue Runner.
The Yarn Project inspector. The configurable properties of the Yarn Project are visible at the top, and the information about the imported project is visible at the bottom.
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.
Creating a new 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.
Yarn Projects include all Yarn Scripts that the project finds in the Source Files directory. By default, that means all Yarn Scripts in the same directory as the Yarn Project, and all of that directory's children.
When you add a Yarn Script to the same folder as a Yarn Project, it will automatically be included in the Yarn Project. When you make changes to the script, the Yarn Project will automatically be re-imported.
You can change the locations that a Yarn Project looks for Yarn Scripts by modifying the Source Files setting. Each entry in the Source Files setting is a search pattern.
You can add as many entries to the Source Files field as you like. If a file is matched by multiple patterns, it will only be included once.
An example of a custom Source Files setting. In this example, the Yarn Project will use all .yarn files in the same folder and its sub-folders, as well as the file Common.yarn in the folder above it.
A Yarn script can be included in more than one Yarn Project.
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.
The 'Create New Yarn Project' button in the Inspector.
- Clicking this button does two things:
- A new Yarn Project will be created next to the Yarn script.
- The new Yarn Project will include the Yarn script you created it from in its list of source scripts.
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.
The Inspector will show information about every variable in the project. If you use a
declarestatement to declare a variable, you can control the initial value of a variable, as well as its description. 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.
The list of variables in a Yarn Project.
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.
Updating the base language of a Yarn Project
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.
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.
If you are upgrading your version of Yarn Spinner from version 2.2 or earlier, you will need to upgrade your Yarn Project. To do this, select the Yarn Project, and click Upgrade Yarn Project.
You will also need to either move all of your Yarn Scripts into the same folder as the Yarn Project, or update the Yarn Project's Source Files setting to tell the Yarn Project where to find your scripts.
Upgrading an old-style Yarn Project from Yarn Spinner 2.2 or earlier
Watch a video where Yarn Spinner developer Jon Manning walks you through upgrading a Yarn Project: