I want to manage HighScore levelwise…For that I am using PlayerPrefs plugin.
I have written below code to manage highscore:
ScoreController Script in JS:
public var highScoreList : List.<int> = new List.<int>();
function Start () {
LoadData();
gameControllerScript = GameObject.Find("Main Camera").GetComponent("GameController");
}
function LoadData()
{
for (var i : int = 0; i < highScoreList.Count; i++)
{
highScoreList *= PreviewLabs.PlayerPrefs.GetInt("highScore" + i);*
}
}
function Update () {
if (!once)
{
-
if(GameController.Score >= gameControllerScript.objectiveScore)*
-
{*
-
if(GameController.HighScore < GameController.Score)*
-
{*
-
highScoreList[GameController.level] = GameController.Score; // Error Comes From Here*
-
Debug.Log("new high score: " + GameController.Score);*
SaveData();
-
}*
once = true;
-
}*
}
}
function SaveData()
{
for (var i : int = 0; i < highScoreList.Count; i++)
{
PreviewLabs.PlayerPrefs.SetInt(“highScore” + i,highScoreList*);*
}
PreviewLabs.PlayerPrefs.Flush();
}
But it gives me ArgumentOutOf range Exception…
So how do i store and update my highscore for perticuler level?
Consol :
Argument is out of range.
Parameter name: index
_System.Collections.Generic.List1[System.Int32].CheckIndex (Int32 index)*_ <em>*System.Collections.Generic.List
1[System.Int32].set_Item (Int32 index, Int32 value)
Pleaze Help me…
Thanx for your Support and Help…