v1.1 (beta 1)
Pre-release
Pre-release
This release adds support for inline expressions and format functions.
NOTE: This release is a beta of v1.1. In addition to a higher risk of bugs, the features and APIs in this version may change in the final release without notice.
Yarn Spinner is made possible by your generous patronage. Please consider supporting Yarn Spinner's development by becoming a patron!
Added
- Added support for inline expressions, which can be used in lines, options and commands.
- You can use inline expressions in lines, options, shortcut options, and commands.
- Inline expressions look like this:
Mae: Wow! I have {$num_pies} pies!
. - When the compiler processes a line that includes an inline expression, the line that's stored in the string table will have each of the expressions replaced with a placeholder. For example, the line above will be stored as
Mae: Wow! I have {0} pies!
. If you're translating a line to other languages, the placeholders can be moved and re-ordered as you need them. - Any expression can be used - numbers, strings, variables, function calls, or more complex expressions.
- The
Line
struct now includes an array of substitutions, which Dialogue UI objects will insert into the localised line at the appropriate place.
- Added support for format functions.
- Format functions are in-line expressions in your scripts that dynamically select text based on a variable. These functions can be localised, which means you can change them based on the needs of the language you're translating the game into.
- Format functions will appear as-is in the .csv string tables that Yarn Spinner for Unity generates, which means that they can be edited by translators.
- Please note that format functions are intended to be a tool for ensuring correct grammar across multiple languages. They are more complex than a simple inline expression, and may complicate your dialogue. They're not intended to replace
if
-endif
structures for your dialogue's logic. - There are three format functions available:
select
,plural
, andordinal
. - The
select
function takes a string variable and uses its value to select a piece of text to use. For example:Character: Wow, [select {$gender} male="he seems" female="she seems" other="they seem"] happy!
- The
plural
function uses a number variable and determines its plural category. For example:Character: Good thing I have {$money_count} gold [plural {$money_count} one="piece" other="pieces"]!
- The
ordinal
function uses a number variable and determines its ordinal category. For example:Character: The race is over! I came [ordinal {$race_position} one="%st" two="%nd" few="%rd" other="%th"]!
- This example also shows how you can embed the variable that the function is using in the result - the
%
character will be replaced the variable's value (in this example,$race_position
, creating text like "I came 3rd!")
- Different languages have different plural rules. Yarn Spinner uses the plural rules defined by the Unicode CLDR; note that not all languages make use of all plural categories.
- Yarn Spinner for Unity will use the Text Language setting in the Inspector to determine which plural rules to apply.
- Yarn Spinner for Unity now uses .asmdef files. Yarn Spinner's Unity code now compiles to a separate assembly.
- IMPORTANT: if you're using asmdefs in your game's code, you will need to add a reference to YarnSpinner.Unity.
Changed
- Yarn Spinner's Unity integration now supports Unity 2018.4 LTS and later. (Previously, the minimum version was unspecified, but was actually 2019.2.)
- Fixed a bug that caused the unary minus operator (e.g.
-$foo
) to cause crashes when it's run. - Unit tests now use test plans, which makes the test cases much more rigorous.