Highscores for each level

Hi

At the moment I have a high-score that is run on each level, it is attached to my main character:

if (PlayerPrefs.GetInt ("highScore") < PlayerPrefs.GetInt("Score") ) {
			PlayerPrefs.SetInt ("highScore",(int)(playerScore * 100));
		}

I then call it in the game over scene:

highScore = PlayerPrefs.GetInt ("highScore");

At the moment the high-score is for the highest score in the game overall. I want to make the high-scores for each individual level.

I’m not sure on how to do this.

I had though it might be similar to the way i have done the restart level button, i have this script:

public static class LevelManager
{
	private static string lastLevel;
	
	public static void setLastLevel(string level)
	{
		lastLevel = level;
	}
	
	public static string getLastLevel()
	{
		return lastLevel;
	}
	
	public static void changeToPreviousLvl()
	{
		Application.LoadLevel(lastLevel);
	}
}

and then i call :

Application.LoadLevel(LevelManager.getLastLevel());

when i want to go back to the last scene.

I’m not sure if there is a similar way to do it with scores.

Thanks

if you want to save the score for each level, just append the level name/number to “highscore” when you save to player prefs. less than elegant, but it’ll work…

I think I can fix the over scenes thing.
Create a JS file called ‘highscores’. It is important to use static variables, or this wont work.

//highscores.js
static var lvl1 = 0;
static var lvl2 = 0;
//And so on

Then, you can call a score like this:
(For instance)

Debug.log(highscores.lvl1);

So, the-name-of-the-script-goes-here.the-variable-you-want-to-use.
Now, if you want to perm save it, you can use other methods, or Unity Serializer.