FAQ
A FAQ for the various components overall Yarn Spinner project.
Last updated
Was this helpful?
A FAQ for the various components overall Yarn Spinner project.
Last updated
Was this helpful?
Wrap the variable (or any expression) in curly braces ({
, }
) to evaluate and output it. For more info, see .
To read and write C# variables from Yarn, you must first code in C#.
See the previous answers on working with variables. But we recommend avoiding any "sync" pattern, because then you'll have to track and maintain the same data in two different places. Programmers usually prefer a .
To save the current node, save the value of somewhere. Then to restore it, call and pass in the saved node name.
To save variables, see . Then to load variables, call . These methods use Unity's built-in JSON utility to serialize a dictionary of variables to the current platforms .
For custom save systems, create your own by subclassing VariableStorageBehaviour and implementing its methods. Study as an example. For more info, see .
To jump to a node from Yarn, use <<jump (nodeName)>>
. See .
To jump to a node with C#, just call . While you can jump to another node while dialogue is running we recommond not doing this and calling before starting another piece of dialogue.
Jumping to a specific line in a node is currently not supported. Instead, .
This is demonstrated by the , which handles this exact scenario (among others). We recommend looking at how it handles the different ways of hurrying up or advancing lines as a starting point for your own games.
Yarn Spinner automatically adds a #lastline
tag to a line when the next step is a set of options. Create a that uses to check for "lastline" and perform the behavior you want.
To display anything in Yarn Spinner, use a component. There are two in-built presenters that demonstrate the basic functionality for lines of dialogue, for dialogue choices.
The samples do have a shared script called the which show off one way to achieve this behaviour.
The math / code is a little complicated. Calculate the NPC's on-screen position, then convert this screen position to UI canvas space, and reposition the dialogue bubble. We do have a that handles all of this (and more) for you if you'd prefer to just have it all working.
This is more about Unity UI rather than Yarn Spinner. For a working example, see the sample.
To make a resizing dialogue bubble that automatically fits text, you will need a complex UI setup. Study the UI game objects and components in the sample scene. For more context about how it works, see .
Once you have the player input value, you can store it in a C# variable and access it through a Yarn function, or store that value in a Yarn story variable. .
The intended workflow is to generate and compile Yarn Projects at editor time, not runtime. See .
Compiling a Yarn script at run-time is more complex than it first appears, because it often interacts with the very specific needs of your game, and we can't provide a one-size-fits-all approach to it. If you want to implement run-time loading in your own game, the place to start looking is the API documentation for the namespace. Please note that this is not something that we encourage people who are new to Yarn Spinner to do!
Localization. 1 Yarn Project = 1 CSV spreadsheet per language. When translating, it is usually easier to work with fewer files, rather than fragmenting the translation across many files. As a workaround for games that need multiple Yarn Projects, you may prefer to create a single editor-only Yarn Project that's just for generating string files and translations. See .
Some devs use YS to manage all in-game localized text, like UI strings. This use isn't intended, but it's possible. Manually create a Yarn.Line struct, set the line ID (see ), and then pass the struct into .
For some reason when you install the package from the Unity Asset Store it has two entries inside the Package Manager. Only one copy of the samples package is installed, you don't have duplicates of the assets and scripts, it just appears in the list twice.
Please visit the for more information.