|
After parsering a text file into an array, I cannot typecast a value within from a string to an int. This usually works for me so I am clueless as to why this is breaking : Error : FormatException: Input string was not in the correct format System.Int32.Parse (System.String s) UnityScript.Lang.UnityBuiltins.parseInt (System.String value)
(comments are locked)
|
|
The error clearly says that the string you pass in is malformed / doesn't contain a number that can be converted. The first thing you should check is: What is in this string! Debug.Log might help. That is the answer to my question I think. When you posted this I was running a debug as it was the same thing in my other question. It's all stemming from the way the .json file is formatted (I'm fairly sure it's tabs that is throwing me off)
Jul 27 '12 at 03:18 PM
alucardj
Well I goofed up on this one. I hadn't removed the commas on this script. So thanks. Although my problem with tabs is still definitely valid : http://answers.unity3d.com/questions/291545/remove-tab-from-parsed-string.html
Jul 27 '12 at 03:49 PM
alucardj
(comments are locked)
|
|
try int.Parse :) parseInt maps to System.Int32.Parse as you can see in the exception above ;)
Jul 27 '12 at 03:09 PM
Bunny83
sorry I meant int.TryParse maybe still not so useful tho..
Jul 27 '12 at 03:13 PM
Seth Bergman
(comments are locked)
|

Thanks to both. It seems I am being bitten by the same *&^$% problem as in my other question : http://answers.unity3d.com/questions/291545/remove-tab-from-parsed-string.html
After running a test to check the length, it is showing one more character than I am expecting.
Why is it I managed to write a reader for .fnt info files , but parsering a texpacker .json is giving me so much hassle ?
I am already cheating on the above question by using
http://answers.unity3d.com/questions/291294/stringequals-not-working-as-expected.html