Search Unity

How to make a best score

Discussion in 'Scripting' started by Simonxzx, Mar 31, 2015.

  1. Simonxzx

    Simonxzx

    Joined:
    Feb 22, 2015
    Posts:
    129
    Hi guys, i'm developing a game in which i want to add a 'best score' scene. How can i do it so that every time the player reaches his best score the game automatically saves it to that scene ? Thank you very much
     
  2. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    You can't save runtime data to a scene, your best to have a bestscores json file that you write to, that your best scores scene reads from.

    That would make it persistent as well so the data will on the disk and be there next time you run the game.
     
  3. Strategos

    Strategos

    Joined:
    Aug 24, 2012
    Posts:
    255
  4. passerbycmc

    passerbycmc

    Joined:
    Feb 12, 2015
    Posts:
    1,741
    Yes it a simpler solution but not as flexable or extendable as serialzing to json or bson since PlayerPrefs really limits your data types. It also can't decribe arrays, dicts or any other advanced data type. Unless you want to use the hackish backdoor method of using the binaryformatter or something like json to serialize complex data into a player pref string.
     
  5. Simonxzx

    Simonxzx

    Joined:
    Feb 22, 2015
    Posts:
    129
    Okay thank you very much guys ! :)