- Home /
comma on PC - dot on Mac
I use Unity on PC and on Mac.
On the Mac side all Numbers in the Transform Inspector are displayed as 1.58375
On the PC side all Numbers are displayed as 1,58375
So one of my scripts and the mu script for MAX/MSP and UNITY communication doesnt work correctly.
Can somebody explain and help???
THX
Also this sucks for my mmo scripts - they always instantiate at a completely wrong position because of the comma problem.
I haven't tried it and I don't know if it helps to change the Regional and language settings from your OS. $$anonymous$$y understanding is that U$$anonymous$$,USA are using '.' and most EU countries follow the French model with a ','. I remember sorting this problem out for a couple of workstations just by modifying the decimal sign in windows. I kept the language as it was and changed the decimal only.
The problem is that you're screwed doing it that way if you're using it for anything networking based - you can't control everyone's computers. The best way is to program it properly in the first place (As in my example below). That way no matter what computer settings they have, it'll interop correctly
Answer by Mike 3 · May 25, 2010 at 03:19 AM
basically you need to use either cultureinfo or numberstyles for doing string to float and back
small example (in js) using the Invariant CultureInfo
import System.Globalization;
var ci = CultureInfo.InvariantCulture;
function Start() { var startFloat : float = 5.1234; var toString = startFloat.ToString(ci); var fromString = float.Parse(toString, ci);
Debug.Log(fromString);
}
This is necessary every time you go from string to float or back, to keep things working on all platforms in different cultures
Note - it'll still print out with the comma in Debug messages (like any float will), but the parsing will no longer break your code like this
Your answer
![](https://koobas.hobune.stream/wayback/20220613023327im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Does parseFloat depend on the OS? 2 Answers
I dont want Decimals :P 1 Answer
What is the max float? -1 Answers
print to only two decimal places. 2 Answers