Decimal points replaced by commas, after switching to .NET 4.

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 :stuck_out_tongue:

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?

I cant help with Unity-specific explanation and solution but yes, I’m sure its a combination of .NET and traditional German formatting (eg c# - German UI Culture de-DE decimal changing to comma value issue in asp.net - Stack Overflow )

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 :confused:

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 :wink:

Perhaps. And that’s great and all. How do I get rid of it? xD

Other than messing up my OS :<

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.

In the editor :confused: I mean… it’s not a big deal, well worth the C# 6 features, if that’s the price. Still, it bugs me :stuck_out_tongue:

Oh well, perhaps this thread will reach the relevant people and someone over at Unity will save my mildly annoyed self from this horror :slight_smile:

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).

1 Like

Great. I hoped I was paranoid for thinking that something along those lines may happen… :confused:

I hope this doesn’t go so far as to affect the whole source control thing. Because that would really suck…

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?

1 Like

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 :eyes: