- Home /
Highscores Input wrong Format Error
Hello Unity Answers! I made my way through setting up Highscores Leaderboard, but when fill in the name and score and submit, I get the following error; Exception: Input string was not in the correct format System.Int32.Parse (System.String s. I have not edited or modified the code. When I hit run it displays a blank leaderboad with Name, Score and Post Score at the top.
GUI.skin = Skin;
windowRect = GUI.Window(0, windowRect, DoMyWindow, WindowTitel);
name = GUI.TextField (new Rect (Screen.width / 2 - 160, 10, 100, 20), name, maxNameLength);
score = GUI.TextField (new Rect (Screen.width / 2 - 50, 10, 100, 20), score, 25);
if (GUI.Button(new Rect(Screen.width / 2 + 60, 10, 90, 20),"Post Score"))
{
StartCoroutine(PostScore(name, int.Parse(score)));
name = "";
score = "";
}
}
The 6th line is the culprit. I've tried adding the name and score in, "", I've tried them both without quotation marks, I've removed the name and score 'labels' and put items in empty text boxes with and without quotations. I've also tried upper and lowercase combinations. I also tried single quotes as a last resort to no good result.Since I didn't change anything, or it's not explained how to format it I can't figure out what is the problem. Can some1 please tell me what condition my condition is in? Help?
Answer by SomeRandomGuy · Nov 29, 2011 at 02:13 PM
Just a thought, but it looks like you are giving you are assigning textfields to a variable calles score, then using that variable inside the textfield and try to print that textfield. Might want to try to rename those variables name and score to namefield and scorefield or something.
I'm not that experienced with unity yet, so I might have just misunderstood your code, but that is what it looks like to me, and it would explain why it is a wrong format error. Good luck!^^;
@JustSomeRandomDutchGuy Thanks! I don't think it's a Unity problem. I did forget to mention it is a C# script. I know less about C# than the bit I've learned about JavaScript. Changing the name of those variables did not work. Thanks again! An 'A' for Effort!
Your answer
Follow this Question
Related Questions
Taking data from text file 2 Answers
Currency String Format 1 Answer
C# inputString mouse Keys? 1 Answer
Shot Counter Question 2 Answers
High Score Name entry 1 Answer