If you are using 4.6 unity it is much easier to do it like this:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class ShowScore : MonoBehaviour {
static int highScore = 0;
public Text guiText;
void Start () {
PlayerPrefs.GetInt("highScore",highScore);
highScore = PlayerPrefs.GetInt ("highScore", highScore);
}
void Update() {
guiText.text = "HS: " + highScore;
}
}
I haven't tested it so if you get any errors let me know. Just wrote it on the spot so probably has errors, maybe not. Hope this helps
**EDIT**: It is very important you include using **UnityEngine.UI;** on top otherwise you will encounter errors!
↧