Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

671
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!