I am getting this error when i try to parse a string to get float value.
FormatException: Input string was not in a correct format. System.Number.ParseSingle (System.String value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) (at :0) System.Single.Parse (System.String s, System.Globalization.NumberStyles style, System.Globalization.NumberFormatInfo info) (at :0) System.Single.Parse (System.String s, System.IFormatProvider provider) (at :0) STLReader+d__34.MoveNext () (at Assets/STLReader.cs:109) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)
Here is the script:
public Text ResultsBaseRes;
float res=0;
public void Create()
{
res = float. Parse(ResultsBaseRes.text);
}
What I have already Tried?
changing the line to
res = float.Parse(ResultsBaseRes.text, CultureInfo.CreateSpecificCulture("en-US"));
res = float.Parse(ResultsBaseRes.text, CultureInfo.InvariantCulture.NumberFormat);
res = float.Parse(ResultsBaseRes.text, CultureInfo.InvariantCulture);
haven't gotten it to convert the string to float till now. i am using Unity 2019.1.8f1.