Frequently Asked Questions / "How Do I...?"
Common questions and solutions for using Yarn Spinner in Rust using Bevy.
Last updated
Was this helpful?
Common questions and solutions for using Yarn Spinner in Rust using Bevy.
Last updated
Was this helpful?
Yarn Spinner doesn't do text rendering, you have to use existing Bevy plugins.
Yarn Spinner doesn't handle text rendering. You'll need a separate wavy text plugin.
Markup lets you mark a range of text (words, phrases) in a generic way, for whatever use. You could use it to style text, add sentence markers, make clickable words, etc.
Note that YS only processes the text data. You must still code the actual markup effect yourself. See .
It is not currently possible to save or restore the specific line that the dialogue is running.
This implementation will vary for every game, so we purposely do not attempt to design a one-size-fits-all generic NPC system. Here's some example pseudocode to make your own:
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.
There is no real technical limit on the number of Yarn scripts or the size of Yarn Projects. You decide how to organize your data, and every project has different needs. Some factors to consider:
Simplicity. Putting everything into one big script file or one big project file is simpler sometimes.
Ease of writing. Writers may prefer to think in terms of one file per scene, one file per chapter.
Wrap the variable (or any expression) in curly braces ({
, }
) to evaluate and output it. For more info, see .
To read Yarn variables from Rust, use . To write Yarn variables from Rust, use
You could hack this with static 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 . Data should live in only one place. Variables should either live in Yarn or live in Rust, and not in both.
To save the current node, save the value of somewhere, e.g. to a .ron
file. Then to restore it, call and pass in the saved node name.
To save variables, fetch them using , then use to read them all and store them again somewhere. Then to load variables, call .
For custom save systems, create your own by implementing and its methods. Study as an example.
To jump to a node from Yarn, use <<jump (nodeName)>>
. See .
To jump to a node with Rust, just call , even if there's already dialogue running.
Jumping to a specific line in a node is currently not supported. Instead, .
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 plugin.
Create a custom dialogue view with a custom effect based on to detect the next text character and pause accordingly.
Write input code to detect clicking / tapping, then call .
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 .
Please visit the for more information. Thanks for thinking of us!