Page 1 of 1

Found issue with Cultures

Posted: Sun Nov 04, 2018 1:59 pm
by ava
Hi all,

I found an issue with cultures. My OS uses comma's as decimal separator instead of points.

This is an issue in Unity's JSON deserialize utility, their parser looks for a hard coded '.' to decide whether or not it's a integer or a float, while in my locale it should be a comma.

https://github.com/Unity-Technologies/U ... iniJSON.cs (around line 322)

As a result, when trying to load an actor with a float value in a field, all its fields become nil.

We cannot fix this ourselves, since it's Unity's serialization that writes a ',' instead of a point. This is probably caused by this issue:

https://issuetracker.unity3d.com/issues ... 2#comments

And won't be fixed until 2019.1

I could fix one part in the pixelcrushers codebase: in Dialogue System/Scripts/Utility/Tools.cs I changed line 95:

Code: Select all

public static float StringToFloat(string s)
{
  float result = 0;
  float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result);
  return result;
}
But it was not enough.

A temporary fix is to write the following line somewhere before the dialogue system gets started:

Code: Select all

System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

Hope this helps anyone running into this issue.
Alex

Re: Found issue with Cultures

Posted: Sun Nov 04, 2018 2:58 pm
by Tony Li
Thanks, Alex. Version 2.0.1 updated Lua Interpreter to be culture invariant in .NET4. I hadn't noticed about JSON. I'll try to make sure this is addressed in version 2.0.6.