Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

678
Visualizações
Unity How to save high score for each specific level?

I have been using unity on and off for a year and still learning. I am trying to create a basic game where a player has to go through levels and collecting points under a time countdown on android. The player will have completed the level once it has hit an endtrigger which would display the amount of points collected along with the time taken to complete it. The high score will then be displayed from the multiplication of the points and time taken, which is simple.

The high score would have already been saved using playerprefs and the high score will then be displayed on the level select screen below each level (ex. lvl 1: 136, lvl2: 245, etc...). I have just learned how to save a simple int using playerprefs.

My problem is, how do I save the high score of each individual level and then display it in the level select screen using playerprefs.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

As in my first comment - PlayerPrefs works with key-value pairs so you can do it like this.

// Setting values
PlayerPrefs.SetInt("Level1", 100);
PlayerPrefs.SetInt("Level2", 200);

// Getting values
int someint = PlayerPrefs.GetInt("Level1");
int someint2 = PlayerPrefs.GetInt("Level2");

So when you want to save it for each level you do something like this.

 //Save Score with scene name as the key and the score as the value
 PlayerPrefs.SetInt(SceneManager.GetActiveScene().name, _score);

You can put it anywhere you want. It will always get the name of the currently active scene as the key.

You can also save floats and strings and also delete entries.

For more information take a look at the Unity docs: https://docs.unity3d.com/ScriptReference/PlayerPrefs.html

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda