Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

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

Discussion in '2018.1 Beta' started by Sentrigal, Mar 29, 2018.

  1. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    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 :p

    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?
     
  2. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
  3. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    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...
     
  4. Alloc

    Alloc

    Joined:
    Jun 5, 2013
    Posts:
    241
    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 ;)
     
  5. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    Perhaps. And that's great and all. How do I get rid of it? xD

    Other than messing up my OS :<
     
  6. Alloc

    Alloc

    Joined:
    Jun 5, 2013
    Posts:
    241
    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.
     
  7. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    In the editor :/ I mean... it's not a big deal, well worth the C# 6 features, if that's the price. Still, it bugs me :p

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

    Alloc

    Joined:
    Jun 5, 2013
    Posts:
    241
    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).
     
    Peter77 likes this.
  9. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    Great. I hoped I was paranoid for thinking that something along those lines may happen... :/

    I hope this doesn't go so far as to affect the whole source control thing. Because that would _really_ suck...
     
  10. Willy-Delcloy

    Willy-Delcloy

    Joined:
    Oct 27, 2015
    Posts:
    6
    The solution I used was to pass CultureInfo.InvariantCulture:
    Code (CSharp):
    1. using System.Globalization;
    2.  
    3. //...
    4.  
    5. float.TryParse(floatString, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
    6.  
    7. // or
    8.  
    9. float.Parse(floatString, CultureInfo.InvariantCulture);  // may throw an exception
    10.  
    11. // and a float to a string:
    12.  
    13. float f = 42.0f;
    14. f.ToString(iItemFormat, CultureInfo.InvariantCulture);
    15. // 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?
     
    juan-jo likes this.
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    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.
     
  12. Sentrigal

    Sentrigal

    Joined:
    Nov 25, 2014
    Posts:
    81
    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 o_O