If you know you will be using 5 players;
PlayerPrefs.GetString("RecordName0", String.Empty);
PlayerPrefs.GetInt("RecordScore0", -1);
PlayerPrefs.GetString("RecordName1", String.Empty);
PlayerPrefs.GetInt("RecordScore1", -1);
PlayerPrefs.GetString("RecordName2", String.Empty);
PlayerPrefs.GetInt("RecordScore2", -1);
PlayerPrefs.GetString("RecordName3", String.Empty);
PlayerPrefs.GetInt("RecordScore3", -1);
PlayerPrefs.GetString("RecordName4", String.Empty);
PlayerPrefs.GetInt("RecordScore4", -1);
The keys could be formatted `String.Format("RecordName{0}", recordIndex);` and `String.Format("RecordScore{0}", recordIndex);`.
Then you could provide methods similar to:
function GetScore(recordIndex : int) : int
{
var key = String.Format("RecordScore{0}", recordIndex);
return PlayerPrefs.GetInt(key, -1);
}
function SetScore(recordIndex : int, score : int)
{
var key = String.Format("RecordScore{0}", recordIndex);
PlayerPrefs.SetInt(key, score);
}
function GetName(recordIndex : int) : String
{
var key = String.Format("RecordName{0}", recordIndex);
return PlayerPrefs.GetString(key, String.Empty);
}
function SetName(recordIndex : int, name : String)
{
var key = String.Format("RecordScore{0}", recordIndex);
PlayerPrefs.SetString(key, name);
}
Then you can get the values like:
var topName = GetName(0);
var topScore = GetScore(0);
With some tinkering about I am sure you can make better, higher level methods like:
function SetRecord(score : int, name : String)
{
// Puts score and name to highscore, pushing worse score off the top 5.
// You wanted to figure out some stuff yourself :)
// But a tip is that you'd use the previous Get/Set methods.
}