Search Unity

Need help with Player Prefs and Highscore

Discussion in 'Scripting' started by K_O_N_S_T_Y, Sep 20, 2019.

  1. K_O_N_S_T_Y

    K_O_N_S_T_Y

    Joined:
    Feb 24, 2019
    Posts:
    50
    In my game the Highscore should be showen in Menu and in the Scene it self. But the Highscore will only be showen in the Main Scene. How can i fix this

    in Update:

    targetDistance.text = PlayerPrefs.GetInt("maxDistance", distanceCanvas).ToString() + " m";
    //max
    if (distanceCanvas > PlayerPrefs.GetInt("maxDistance",0))
    {
    PlayerPrefs.SetInt("maxDistance", distanceCanvas);
    }
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    With 44 posts you should know by now that people would like you to use code tags. Not only should you know, but when i looked through your threads i found people telling you every time you posted code examples, to use code tags. So i just gotta ask: Is there a reason why you are ignoring that request? Code tags just add readability through formatting and syntax highlighting. You can add your code with code tags by using the <> button when posting something. It's also the first sticky on this subforum.
     
  3. K_O_N_S_T_Y

    K_O_N_S_T_Y

    Joined:
    Feb 24, 2019
    Posts:
    50
    Sorry nobody told me
     
  4. Dextozz

    Dextozz

    Joined:
    Apr 8, 2018
    Posts:
    493
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please show the code (using code tags!) where you set the menu text. And your code that you have above shows maxDistance, not Highscore. Where are you calculating and storing the score?