Hello, all! I'm having a problem with float.Parse I'm using this code to covert strings to floats.
int amount = 0;
for (int i = 0; i < lines.Length / 3; i++)
{
print(lines[i]);
Instantiate(cube, new Vector3(float.Parse(lines[amount], System.Globalization.CultureInfo.InvariantCulture), float.Parse(lines[amount + 1], System.Globalization.CultureInfo.InvariantCulture), float.Parse(lines[amount + 2], System.Globalization.CultureInfo.InvariantCulture)), Quaternion.identity);
amount++;
amount++;
amount++;
}
The last print before I get the error in the console print(lines[i]) gives "-0.5"
The error I'm getting is `FormatException: Unknown char: -
System.Double.Parse (System.String s, NumberStyles style, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Double.cs:209)
System.Single.Parse (System.String s, IFormatProvider provider) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/Single.cs:193)
LevelEditorManager+c__Iterator2.MoveNext () (at Assets/LevelEditorManager.cs:180)
` Please help :)
↧