How to keep Highscores?

Hello. I would like my game to be able to keep highscores but I’m not sure how to do so. I have seen some answers concerning that but I don’t quite understand. Do I have to use “PlayerPrefs” to keep the score? How do I display it at the end of the game; do I have to create another scene? This is the current score scripts that I’m using.

Attached to GUI text:

static var score : float = 0;

function Update () 
{
	guiText.text = "Score : " + score;
}

This is the script to increase the score:

var score = 0;

function OnTriggerEnter (other : Collider) 
{
	keepscore.score += 25;
	gameObject.active = false;
	Destroy(gameObject); 
}

Thank you for your help.

1 Answer

1

I would recommend reading up on the System IO functionality of .NET which is available to UnityScript. I attached the link below. You can use it to create a file and store your high scores in, then read it back when you reopen the game and import the data.

System IO

Here’s a link that helps me figure out System IO.

Unity Post for System IO

This link should help Javascript specific questions on Read and Write.

Javascript Read Write external file