I am trying to use the “roll- a-ball” example to testing the “playerprefs” class but no luck.
my idea is using the “playerprefs” to store how many time the ball drop into the black hole. However, the data is reset to 0 after exiting the games.
Here is my code:
var scoreDisplay : GUIText;
var LastScore : GUIText;
var score : int = 0;
function OnTriggerEnter (other : Collider)
{
other.gameObject.active = false;
score += 1;
scoreDisplay.text = "SCORE: " + score;
PlayerPrefs.SetInt (“Saved Var”, score);
var theVarToSave: int = PlayerPrefs.GetInt (“Saved Var”);
LastScore.text = "LastScore: " +theVarToSave ;
yield new WaitForSeconds (5);
other.gameObject.active = true;
}
Can anybody give me a walkthrough?
thanks!!