Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by stefan kolbe · May 25, 2010 at 02:10 AM · floatlocalizationdecimalos

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

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image user-1846 (google) · May 25, 2010 at 02:27 AM 0
Share

I have the same problem. Please help us :)

avatar image user-1846 (google) · May 25, 2010 at 02:28 AM 0
Share

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

avatar image alexnode · May 25, 2010 at 08:18 AM 0
Share

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.

avatar image Mike 3 · May 25, 2010 at 10:57 AM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
2

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mike 3 · May 25, 2010 at 03:25 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Does parseFloat depend on the OS? 2 Answers

Unity/C# ignores decimal after it reach some value 1 Answer

How do I get rid of the numbers after the decimal? 2 Answers

On the accuracy of floats and doubles: Where/when do rounding errors usually occur, and how can I avoid them? 1 Answer

Playerpref.SetInt enterd with a float. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges