Local high scores

Hi guys, I’d really appreciate your help at this time.

I’m making a simple little game wih a number of levels(scenes). I have a score counter that works correctly but am unsure as to what I need to do for the following:

  1. When the player finishes a level, how do I take their score and display it in a new scene?
  2. How do I create a high score mechanic for each level which contains the best score that the player has achieved on each level so far? (I don’t need player names or a list of scores, just their previous best).

I’ve been scripting so far in C# and the game mechanics are pretty much in place. However this is my first experience of wanting to share or transfer data between scenes.

Many thanks.

How about PlayerPrefs.SetInt()
http://download.unity3d.com/support/documentation/ScriptReference/PlayerPrefs.SetInt.html

The simpliest way is to use static properties. These don’t get flushed away when you do Application.LoadLevel(…). For safety, don’t inherit your class from MonoBehaviour or some other Unity-managed class.

public class HighScoresStorage {

  public static Map<string, int> scores; // player name => score

}

As lidapow had said use the PlayerPrefs. you would use the function (sorry for javascript syntax, i know how to use C# but i speak in Javascript :stuck_out_tongue: ) PlayerPrefs.SetFloat(“NameofVarHere”,Thevaluehere); Use PlayerPrefs.GetFloat(“Whateveryoucalledit”); to get the value back. So you would save it at the end of the scene, and then access it at the beginning of the next scene. if you need more help let me know :wink: