I get this error: GetInt can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
#pragma strict
guiText.fontSize=Screen.width/25;
var highscore:int=PlayerPrefs.GetInt("highscore",0);
function Update(){
PlayerPrefs.SetInt("highscore",highscore);
guiText.text=highscore.ToString();
if(score>highscore){
highscore=score;
}
}
I don't actually use "score" but I just wanted to show the code logic.
↧