After switching from the legacy to the stable runtime, Unity restarts and suddenly all decimal points are commas. Not a big deal, but it’s bugging me
Now, I have no idea if this even has anything to do with the beta, but since it happens (reliably) after switching runtime, I assume, in one way or another, it does. Any ideas what could be causing this and how to get my decimal points back? Note: I’m German, so naturally I use a German OS version, in case that’s the underlying cause…
Additionally, after Unity restarts after a switch, all files within the project are named with… unknown characters. It quickly returns back to normal, but it sure is weird and possibly related? Has anyone else observed any of this?
Right. Did some more testing and it turns out changing the culture in Windows does, technically, fix it. Of course it also messes with everything else, which I’d rather avoid lol. Any ideas?
What’s bothering me most is that I don’t understand why that only happens now. You’d assume if this was a thing, it would’ve been a thing since forever, no? Why only now? And why only when using the new runtime? Hm
So… still looking for a solution that does not involve messing up my habits. I could, in principle, use the en-US culture or even an English Windows without any issue. But … you know, habits and things…
Maybe the Mono runtime is finally handling locales the same on Windows (and OSX?) as it already did on Linux, i.e. default to the system locale instead of the english or culture invariant one. Was a pain in the ass as developers didn’t care about properly writing their code so their files would load fine everywhere
Editor or player? In players you have to take care of it yourself by using the ToString / (Try)Parse overloads that accept an IFormatProvider and pass the CultureInfo.InvariantCulture. Editor: Unity would have to provide something for that.
My only fear would be that they also have this issue in their serialization code, e.g. when saving text based assets, and that devs with locales that use “,” as decimal sep would break the projects (haven’t yet tried with the new runtime so far so can’t say myself).
The solution I used was to pass CultureInfo.InvariantCulture:
using System.Globalization;
//...
float.TryParse(floatString, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
// or
float.Parse(floatString, CultureInfo.InvariantCulture); // may throw an exception
// and a float to a string:
float f = 42.0f;
f.ToString(iItemFormat, CultureInfo.InvariantCulture);
// iItemFormat can equals to "G". See MS docs.
Unity ToString() functions (for instance Vector3) do not support a way to change the Culture so you will end up with “,” as decimal separator if your computer runs in French… Dear Unity’s developers could you fix that?
Our serialization is implemented in C++ and isn’t affected by the scripting runtime. However, if you find this still is broken, we’d like a bug report on it.
So… does this mean it’s most likely just a cosmetic thing? Because I’m even in the beta to check out new features for stuff I’ve planned for the store. And I’d rather not bork the project of anyone using any resulting assets or anything