In Keeping score and recording the score with this script:
var score = 0;
var scoreText = "Score: 0";
var mySkin : GUISkin;
function OnTriggerEnter( other : Collider ) {
Debug.Log("OnTriggerEnter() was called");
if (other.tag == "Coin") {
Debug.Log("Other object is a coin");
score += 100;
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
Destroy(other.gameObject);
}
}
function FixedUpdate(){
Debug.Log("OnTriggerEnter() was called");
score += 1;
scoreText = "Score: " + score;
Debug.Log("Score is now " + score);
if (score > PlayerPrefs.GetInt ("Points")) {
PlayerPrefs.SetInt("Points", score);
}
}
function OnGUI () {
GUI.skin = mySkin;
GUI.Label (Rect (10, 10, 500, 200), scoreText.ToString()); }
And I'M calling the "Points" Number with :
var score = 0;
var scoreText = "Score: 0";
var mySkin : GUISkin;
function Start() {
PlayerPrefs.GetInt ("Points");
scoreText = "High Score: " + PlayerPrefs.GetInt ("Points");
}
function OnGUI () {
GUI.skin = mySkin;
GUI.Label (Rect (500, 10, 200, 500), scoreText.ToString()); }
-These scripts work in the unity editor. when the score is more than the best score it is changed. But when it is built and put on the device the score GUI isn't displayed and "Best Score" system doesn't work. How can i use fix this? Why isn't PlayerPrefs working on iPhone?
Im sorry about the code formatting I can't get it formatted no matter how hard I try.
-Thanks