x


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

more ▼

asked May 25 '10 at 02:10 AM

stefan kolbe gravatar image

stefan kolbe
11 1 1 2

I have the same problem. Please help us :)

May 25 '10 at 02:27 AM user-1846 (google)

Also this sucks for my mmo scripts - they always instantiate at a completely wrong position because of the comma problem.

May 25 '10 at 02:28 AM user-1846 (google)

I haven't tried it and I don't know if it helps to change the Regional and language settings from your OS. My understanding is that UK,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.

May 25 '10 at 08:18 AM alexnode

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

May 25 '10 at 10:57 AM Mike 3
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered May 25 '10 at 03:19 AM

Mike 3 gravatar image

Mike 3
30.7k 10 67 255

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

May 25 '10 at 03:25 AM Mike 3
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x185
x24
x20
x15
x1

asked: May 25 '10 at 02:10 AM

Seen: 1186 times

Last Updated: May 25 '10 at 12:27 PM