Learn about Yarn Projects, which group your scripts together for use in a Dialogue Runner.
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 script.
This new Yarn Project will be empty, and won't contain any references to other Yarn scripts yet.
On their own, a Yarn Project doesn't do anything. In order to be useful, you need to add Yarn scripts to it.
When a Yarn Project has no scripts added to it, you'll see this warning in its Inspector.
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.
Adding scripts to a Yarn Project.
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.
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 be set up to 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.
This information comes from the following locations:
- All variables that have been declared in a Yarn script with a
- All variables that have been manually added to this Yarn project
- All variables that are used, but don't have a
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.
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.