Okay so I have level where the player gets a score the score is being saved in a playerpref when the player collides with the goal object, another scene is being loaded with a menu thing. Okay so here is the code for the player:
if(collision.gameObject.tag == "Goal"){
PlayerPrefs.SetInt("PrewScore", score);
PlayerPrefs.SetInt("PrewLevel", Application.loadedLevel);
Application.LoadLevel(2);
}
And here is the code fore the menu:
print(PlayerPrefs.GetInt(“PrewScore”));
var starClone : Transform;
if(PlayerPrefs.GetInt(“PrewScore”) == 1000){
starClone = Instantiate(star, starSpawn1.position, starSpawn1.rotation);
}else if(PlayerPrefs.GetInt("PrewScore") == 2000){
starClone = Instantiate(star, starSpawn1.position, starSpawn1.rotation);
starClone = Instantiate(star, starSpawn2.position, starSpawn2.rotation);
}else if(PlayerPrefs.GetInt("PrewScore") == 3000){
starClone = Instantiate(star, starSpawn1.position, starSpawn1.rotation);
starClone = Instantiate(star, starSpawn2.position, starSpawn2.rotation);
starClone = Instantiate(star, starSpawn3.position, starSpawn3.rotation);
}else if(PlayerPrefs.GetInt("PrewScore") == 4000){
starClone = Instantiate(star, starSpawn1.position, starSpawn1.rotation);
starClone = Instantiate(star, starSpawn2.position, starSpawn2.rotation);
starClone = Instantiate(star, starSpawn3.position, starSpawn3.rotation);
starClone = Instantiate(star, starSpawn4.position, starSpawn4.rotation);
}else if(PlayerPrefs.GetInt("PrewScore") == 5000){
starClone = Instantiate(star, starSpawn1.position, starSpawn1.rotation);
starClone = Instantiate(star, starSpawn2.position, starSpawn2.rotation);
starClone = Instantiate(star, starSpawn3.position, starSpawn3.rotation);
starClone = Instantiate(star, starSpawn4.position, starSpawn4.rotation);
starClone = Instantiate(star, starSpawn5.position, starSpawn5.rotation);
}
You can see that I also try to print the pref but it just shows as zero.
Any ideas??