[FIXED][SteamVR] Display HighScore

Hi !

I have 5 Differents level, One is my menu where you can select your world ( 4 choice ) What i want it to display the Score + The HighScore of each level on my Menu level. BUT i’m in VR so i can only display those value on an world space GUI …

So that way didn’t work :

[URL='http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=GUI']GUI[/URL].[URL='http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=Label']Label[/URL](new [URL='http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=Rect']Rect[/URL](winScreenRect.x + 20, winScreenRect.y + 100, 300, 50), "High Score  " + [URL='http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=PlayerPrefs']PlayerPrefs[/URL].[URL='http://unity3d.com/support/documentation/ScriptReference/30_search.html?q=GetInt']GetInt[/URL]("High Score"));

I have my ScoreManager who save my score for each level in PlayerPerfs like that :

if(currentScore > PlayerPrefs.GetInt("High Score"))
{
           PlayerPrefs.SetInt("Level " + currentLevel.ToString() + "High Score", currentScore);
           highScore = currentScore;
           PlayerPrefs.SetInt("High Score", highScore);
}

But i don’t know who display that on my GUI

Thanks :slight_smile:

You should be using the Unity Text UI and simply assigning the values to the text part of it

For example

public Text lvl1score; //drag and drop lvl1 text here

void Start()
{
    lvl1score.text = PlayerPrefs.GetInt("Level1HS").ToString();
}

Yes that an good idea.

But i have an problem for get the “currentlvl” because the player could select the lvl he want not in the order of the level index :/. Do you have an idea ?

 Scene sceneLoaded=SceneManager.GetActiveScene();

I try something like that, but that include i need to write one Scoremanagement per level for get the number of the scene and save the score & hs for this scene in PlayerPerf, and call the scene & score by the script you told me

Someone have an idea ?

I’m not sure I understand the question. If you are on a level and want to use the scene name as part of your highscore key, then just do

PlayerPref.SetInt("HS" + SceneManager.GetActiveScene().name, score);

Then you should be able to get all scene names in your main menu and get the scores to display them.

Problem saved, i tried to save an Int to an String so Unity return null …

Thanks to everyone