update to unity 2019 and float.TryParse going to delete my decimal point

Can somone help me when i use

  string[] values = {"160.519" };
    // Start is called before the first frame update
    void Start()
    {
   
      foreach (var value in values)
      {
         float number;
  
         float.TryParse(value, out number);
          Debug.Log(""+number);
            
    }

I get

160519
UnityEngine.Debug:Log(Object)

Why i get this?
In unity3d 2018 its works perfect!

Works just fine for me. What else are you doing in that script?

i have in unity 2018 scripting runtime net 3.x and in unity 2019 net 4.x.

Edit : change to 4.x and you become the same bug debug give you 160519
And when you use 3.x you become in the debug.log 160.519 very confused

Probably this, related to locale

1 Like

thx for that here is the fix from @gresolio https://discussions.unity.com/t/646991/42

just create a c#file with the name FixCultureEditor and copy past the code from @gresolio

using System.Globalization;
using System.Threading;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
#if UNITY_EDITOR
[InitializeOnLoad]
public static class FixCultureEditor
{
    static FixCultureEditor()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
    }
}
#endif
public static class FixCultureRuntime
{
    [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
    static void FixCulture()
    {
        Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
    }
}

Hope unity fix this with the decimal point bug