What I'm doing is having all of the highscores on my game be sent to a server, and then transmitting them back to the game. The exception reads as follows: "FormatException: Input string was not in the correct format."
It says it's coming from the line of code in which I utilize the Int.Parse function (one of which I have never used until now).
Here is the code:
IEnumerator GetScores()
{
//this.gameObject.guiText.text="Loading Scores";
//gameObject.guiText.text = "Loading Scores";
print ("Loading Scores");
WWW hs_get = new WWW(highscoreURL);
yield return hs_get;
int index=0; // Index of my loop
print(HighNumbers.Length);
string sTemp=hs_get.text; // putting the highscore text into a string called sTemp
string[] lines = Regex.Split(sTemp, " "); // Splitting it based on spaces - should probably be changed to | but fuck it i'll do that later
foreach (string line in lines){
int i;
HighNumbers[index]=int.Parse(lines[index]); // putting the content of line (which was split based on spaces) into index of HighNumbers
print(HighNumbers[index]);
index++;
ScoresLoaded = true;
}
}
Some people on the Unity forums told me to try Int.TryParse, but I don't know exactly how that would be implemented specifically for this code.. I have seen some examples of TryParse, but nothing that I could actually figure out how to utilize for this script. So, they eventually told me to go to a c# specific forum, and since I've been coming here for years now, I figured this would be a great place to post.
All I'm asking for is a little guidance. A simple push in the right direction would more than suffice. Thank you!

New Topic/Question
Reply



MultiQuote



|