I’m making a highscore box in the main menu. In the script I have, i’ve gotten it down to one error on this line:
hscorecount == PlayerPrefs.GetInt(highScoreKey, 0);
The error: CS0201: ‘Only assignment, call, increment, decrement, and new object expressions can be used as a statement’.
All the code:
void Start()
{
//Get the highScore from player prefs if it is there, 0 otherwise.
hscorecount == PlayerPrefs.GetInt(highScoreKey, 0);
}
void Update()
{
GetComponent<GUIText>().text = "Score: " + score.ToString();
}
void OnDisable(){
//If our scoree is greter than highscore, set new higscore and save.
//for (i = 0; i<hscorecount.Length; i++){
//Get the highScore from 1 - 5
// highScoreKey = "HighScore"+(i+1).ToString();
//hscorecount = PlayerPrefs.GetInt(highScoreKey,0);
//if score is greater, store previous highScore
//Set new highScore
//set score to previous highScore, and try again
//Once score is greater, it will always be for the
//remaining list, so the top 5 will always be updated
if(score > hscorecount){
int temp = hscorecount;
PlayerPrefs.SetInt(highScoreKey,score);
score = temp;
}
}
}