You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using custom commands that expect float parameters in yarn, e.g., <<sleep>> float literals (e.g., <<sleep 0.5>>) behave as expected. However, when using variables (such as <<sleep {$delay}>> in a locale that uses "." as a thousands separator, such as de-AT, the float is converted to a locale aware string (e.g., "0,5") but then back to a float using an InvariantCulture when calling the custom command.
Please provide the steps to reproduce, and if possible a minimal demo of the problem:
Run the following in an OnAwake() somewhere to force the system locale to German (AT).
using System.Globalization;
// ...
void Awake() {
Thread.CurrentThread.CurrentCulture = new CultureInfo("de-AT");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-AT");
}
Then in a yarn script:
<<declare $delay = 0.5>>
Let's wait for a half-second...
<<wait {$delay}>>
Done!
The "Done" dialogue will take 5 seconds to appear instead of 0.5 seconds.
What is the expected behavior?
Since we are using a properly typed float variable, and passing it to a command that expects a float, I expect there to be no unnecessary computations of string formatting or parsing to happen, and the "Done" dialogue to appear after a half-second delay instead of five seconds.
Locale aware string formatting would still be expected when using {$value} to format a float var into user-visible dialogue, as well as commands that expect strings/text but a float was passed.
This was partially fixed as referenced in YarnSpinnerTool/YarnSpinner#369 but the long term issue persists.
For now the format_invariant method provides a workaround until we can come to some long term solution.
What is the current behavior?
When using custom commands that expect float parameters in yarn, e.g.,
<<sleep>>
float literals (e.g.,<<sleep 0.5>>
) behave as expected. However, when using variables (such as<<sleep {$delay}>>
in a locale that uses "." as a thousands separator, such as de-AT, the float is converted to a locale aware string (e.g., "0,5") but then back to a float using an InvariantCulture when calling the custom command.Please provide the steps to reproduce, and if possible a minimal demo of the problem:
Run the following in an OnAwake() somewhere to force the system locale to German (AT).
Then in a yarn script:
The "Done" dialogue will take 5 seconds to appear instead of 0.5 seconds.
What is the expected behavior?
Since we are using a properly typed float variable, and passing it to a command that expects a float, I expect there to be no unnecessary computations of string formatting or parsing to happen, and the "Done" dialogue to appear after a half-second delay instead of five seconds.
Locale aware string formatting would still be expected when using
{$value}
to format a float var into user-visible dialogue, as well as commands that expect strings/text but a float was passed.Please tell us about your environment:
Other information
Link to discord discussion in #help
The text was updated successfully, but these errors were encountered: