Multiple playerpref integers?

Hello. How can I store/display multiple copies of the same string using PlayerPrefs (for a local high score table)? How can I store (I have looked at the Array Prefs on the wiki, and I dont quite understand how to use it with my existing playerpref script :() My script uses the different combinations of options for my game to create a unique high score for each combination (so easy-character1 has a different score than hard-character2). Also, how can I order the integers from greatest to least to display on the high score table? Thanks

function Update () 
{
    var Arcade : String = System.String.Format("{0}{1}{2}_score", Arcade.ModeInt, Arcade.DifficultyInt, Arcade.CharacterInt);
    PlayerPrefs.SetInt(Arcade, Stats.Score);
}

You can use PlayerPrefs like this… although it’s a hack :wink:

Writing…

int counter = 0;
PlayerPrefs.SetInt("Arcade" + counter, 100);
counter ++;
PlayerPrefs.SetInt("Arcade" +counter, 200);
counter ++;
PlayerPrefs.SetInt("ArcadeTotalCount",counter);

Reading…

for (int i = 0; i < PlayerPrefs.GetInt("ArcadeTotalCount"); i ++)
{

  myvariable = PlayerPrefs.GetInt("Arcade" + i);

}

There are probably other (maybe better) options (such as using the ‘array’ prefs’ script or scripts that you mentioned), but one solution would be to store all the scores for a particular combination of options in a single string. For example, if there are 5 scores in the list, the string might look like this:

5000_4500_1100_400_100

When loading the scores from PlayerPrefs, you’d parse the string using (e.g.) string.Split(), and then convert the strings to integers. When saving the scores you’d do the opposite.

For sorting the scores, you can use one of the ‘sort’ function supplied by the .NET library, such as Array.Sort().