i m making a score system for a game, and i want to save the score when moving over to the next scene, and then taking that score that i ve saved, and increment it every second. this is what i have:
void Start ()
{
score = 1;
MaxLevelScore = 600;
}
// Update is called once per frame
void Update ()
{
score++;
saveScores();
changeLevel();
}
public void changeLevel()
{
if (score == 600)
{
//save the score to carry over to the next level
// load the level index here
Application.LoadLevel("Level2");
saveScores();
}
if(Application.loadedLevelName == "Level2")
{
getSavedScores();
}
}
//possible if the save functionality intreacts with this
public void saveScores()
{
if (score == 600)
{
// setting the score
PlayerPrefs.SetInt("MaxLevelScore", 600);
}
}
public int getSavedScores()
{
int tempScore = PlayerPrefs.GetInt("MaxLevelScore");
return tempScore;
}
public int getScore()
{
return score;
}