Hey guys. Can anyone help me please with this problem I’m having? I want to be able to record the time it takes for each player to complete my game and display it with the times from the other players. Kind of like a leader board. Currently my game will record and store all the times from the previous players as well as the current gamer. The problem exist when I come to display all the times from the people that played my game. As when it does display it overwrites the previous time that was being displayed. Here is my snippet of code:
var SavedTIME2COMPLETEgame;
static var displaySTRING;
function Update () {
if(Input.GetKeyDown("o") && Dist_To_COMPLETELEVEL < 2){
STOPtime = false;
Application.LoadLevel("Completed Level Thirty Seconds");
//SavedTIME2COMPLETEgame(timeRemaining);
SavedTIME2COMPLETEgame = timeRemaining.ToString();
//PlayerPrefs.SetString("", );
//displaySTRING = PlayerPrefs.GetString("", timeRemaining);
print(SavedTIME2COMPLETEgame);
SavedTime(SavedTIME2COMPLETEgame);
//Display_Recorded_Time(SavedTIME2COMPLETEgame);
//DontDestroyOnLoad(GameManager2);
}
}
function SavedTime(SavedTIME2COMPLETEgame : String) {
displaySTRING = PlayerPrefs.GetString("", SavedTIME2COMPLETEgame);
Debug.Log(displaySTRING);
}
The above piece of code is from my main game scene. The following piece is from the complete level/game scene:
function OnGUI () {
GUI.Label(new Rect (10, 10, 100, 100), "Time Recorded: " +GameManager2.displaySTRING);
}
Help much appreciated. Thank you.