For our Splume levels we used simple serialization–just a list of numbers with tab delimiters. A lot of people were reporting broken levels, and we found out why:
If you write floats, and later read with float.Parse(), you must define localization settings. Our floats looked like: 3.98234. Other locales flip commas/periods, though, so when they parse that they get 398,234.00 (a really large number, instead of a really small one)
The solution is to do:
float.Parse(someString, System.Globalization.CultureInfo.InvariantCulture.NumberFormat)
You can import System.Globalization.CultureInfo or some other path to shorten that, of course. Make sure you also pass in the same to all of your ToString() calls when you write, too.
Ahh - we hit that in GC:Palestine as well - right at the end of the debugging cycle, we switched a variable from int to float, so we could represent .5 (or ,5)…
Hated those 2 days spent hunting that one down
You can also get around this problem by adding
System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
to some Start/Awake function.
This changes the default formatting, so you don’t need to specify it in every subsequent ToString() call. Of course, it’s probably a bad way to go if you actually want to display those localized numbers anywhere.
… (will move to new thread) …
Sorry for the confusion, polytropoi - I was responding to the op, not to your post specifically.
Looking at your code: you’re trying to turn an array of strings into an array of floats? I believe float.Parse() only works on a single string at a time; you’d need to loop through your array to convert it.