Hello everyone
I have been developing a racing game
and when you finish the race it goes to a highscore scene and you type your name there and your time appears in front of it
and then it goes back to the main menu
but i have a problem
instead of recording the name and score and going to the main menu it just stands there and i can´t stop to write the name
if someone could please help me
here is the important part of the script (if you need to see the total script just ask):
// This stores the score and name of the players
class Entry {
var score = 0.0;
var name = "";
}
private var entries = ArrayList ();
// How many high score entries are shown?
var maxEntryCount = 10;
// How long is the player’s name allowed to be?
var maxNameLength = 8;
function Awake () {
// Load the entries from prefs
LoadEntries ();
// And display high score table text.
SetupHighscoreTableText ();
}
// This is a coroutine which runs until the user has entered his name.
// To enter a new highscore in the table do like this:
// highscoreTable.StartCoroutine ("EnterHighScore", 10);
function EnterHighScore (score : float) {
// Setup the highscore table text
SetupHighscoreTableText ();
// Insert the entry, it might get rejected if the score is not high enough
var entryIndex = InsertEntry (score);
if (entryIndex == -1)
return;
// Check for the last name the user entered and reuse it
var inputName = PlayerPrefs.GetString ("LastHighscoreName");
while (true) {
for (var c : char in Input.inputString) {
// Backspace - Remove the last character
if (c == "\b"[0]) {
if (inputName.Length != 0)
inputName = inputName.Substring(0, inputName.Length - 1);
}
// End of entry.
else if (c == "\n"[0]) {
if (Input.GetKeyDown ("Enter")) {
Application.LoadLevel ("Menu");
}
// But the user must have at least entered something
if (inputName.Length)
{
ChangeName (entryIndex, inputName);
SaveEntries ();
// Store the name the user entered as the last high score name,
// so next time the user doesn’t have to enter it again
PlayerPrefs.SetString ("LastHighscoreName", inputName);
return;
}
}
// Normal text - just append
else {
inputName += c;
}
}
// Make sure the name doesn’t grow above max entry length
if (inputName.Length > maxNameLength)
inputName = inputName.Substring (0, maxNameLength);
// Add a "." as a blinking text marker.
// Show the "." every .5 seconds
blinkingName = inputName;
var time = Mathf.Repeat (Time.time, 1.0);
if (time > .5)
blinkingName = inputName + "|";
else
blinkingName = inputName;
// Change the name
ChangeName (entryIndex, blinkingName);
yield;
}
}