c# - Unity 5 - Playerprefs saving in unity but not on android? -


i have attached hero object gets destroyed . part of problem? want save highscore display on start scene. here code:

public int highscore;  public int score;      void addpoint1() {       if (score > highscore) {         highscore = score;         playerprefs.setint ("highscore", score);         playerprefs.save ();      } } 

here second script attached empty object in start scene (different scene)

void ongui() {      gui.label (new rect (screen.width / 2, screen.height/2, 100, 100), "highscore: " + playerprefs.getint("highscore"), customguistyle); } 

from knowledge of unity not need call playerprefs.save(), i've noticed have highscore stored locally , never defined, therefore comparing score null value. new code this:

public int score;  void addpoint1() {      if(score > playerprefs.getint("highscore"))      {            playerprefs.setint("highscore", score);      } } 

also if set highscore something, 1. code work close application , rerun highscore reset one, , if player scored 2, override playerprefs highscore no matter is.


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -