Repository navigation
This is the compiler for Yarn Spinner. If you want to use Yarn Spinner in a Unity game, please see the releases page for Yarn Spinner for Unity!
Yarn Spinner is made possible by your generous patronage. Please consider supporting Yarn Spinner's development by becoming a patron!
Async Yarn Spinner
The API for Dialogue and VirtualMachine has been updated to be asynchronous. This is a breaking change for anyone directly using Yarn Spinner as a library.
The main goal behind this change is to allow game engines to take time reacting to changes in the dialogue. Nearly every event that can be raised from Yarn Spinner, from lines to options to function calls to nodes starting and engine, is now handled asynchronously.
- Dialogue is now async.
StartDialogueandStartnow return aValueTaskwhich completes when the dialogue has completed running. IDialogueResponderreplaces handler delegates. TheDialogueobject no longer exposes raw delegates to invoke when events occur. Instead, implement theIDialogueResponderinterface, and provide that to theDialogue'sResponderproperty. The Dialogue Responder is responsible for mediating theDialogue's interactions with the outside world.IDialogueResponderalso replaces theLibrary. Previously, functions were handled by supplying aLibraryobject that contained the implementations of the functions. This responsibility has been moved to theIDialogueResponderinterface: theCanCallFunctionmethod returns a boolean indicating whether the responder is capable of handling a function, and if it can, theInvokeFunctionis called with the function name and parameters, as well as a cancellation token, and returns aValueTaskcarrying the return value.- Functions in Yarn Spinner are now async. The task returned by your dialogue responder's
InvokeFunctionmethod is allowed to take as long as it needs, and doesn't need to return immediately. The virtual machine will suspend until it's finished. - Functions in Yarn Spinner are now cancellable. If the cancellation token that's passed to
InvokeFunctionbecomes cancelled, the dialogue no longer needs the return result, and your method should return as soon as possible. - Commands in Yarn Spinner are now cancellable. In addition to functions, the corresponding command handling method in
IDialogueResponder,HandleCommand(), takes a cancellation token. If the cancellation token becomes cancelled, the method should return as soon as possible. - Undeclared functions are now errors. In previous versions of Yarn Spinner, using a function that wasn't declared to the compiler was permitted, because the compiler would attempt to figure out the type of the function. This has been removed in Yarn Spinner 3.3.
- In order to assist with the migration from previous versions of Yarn Spinner, if your
.yarnprojectfile was created by a previous version, undeclared functions will result in a warning and will prompt you to upgrade your project. Note that not all features from Yarn Spinner v3.3 may be available until you upgrade your project file.
- In order to assist with the migration from previous versions of Yarn Spinner, if your
Other Changes
- The C# source code generator that was originally written for use in Unity has been migrated to the core repo, so that it can be used in additional engines.
DescriptiveLineTagGeneratornow removes whitespace from character names- This does technically mean if you have two characters with the same name but different spacing, the tagger will consider them the same character. This felt uncommon enough to not handle.
<<call>>commands now clean up the stack by discarding the returned value.ILineTagGeneratorhas been moved to theYarn.Compilernamespace. (Previously, it was in the global namespace.)- Node titles now trim any trailing whitespace that might be present. (Fixes #156; thanks to @DontDieThankYou)
- Markup parsing now correctly handles character names that have "'s in their name
- Calls to
visitedandvisited_countnow correctly cause tracking to occur when inside a nested function call (e.g.max(visited_count("X"), visited_count("Y)))) - User-defined types (for example, enums) are now detected and processed before the rest of the typechecking process begins.
- This fixes an issue where the compiler would take a very long time to type-check expressions whose value came from an enum that had not yet been processed. (Thanks to Discord user Talsidor for reporting the problem!)
