Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

HIgh Score on web player

Discussion in 'Scripting' started by Andy, Apr 6, 2007.

  1. Andy

    Andy

    Joined:
    Nov 5, 2006
    Posts:
    50
    Is there a way to do highscore on a web browser game?

    thanks
     
  2. forestjohnson

    forestjohnson

    Joined:
    Oct 1, 2005
    Posts:
    1,370
  3. Andy

    Andy

    Joined:
    Nov 5, 2006
    Posts:
    50
    Actually I was meaning highscore that remains on a local computer. I don't think I am ready to tackle the web yet, although that day will come.

    thanks
     
  4. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
  5. spazy_t

    spazy_t

    Joined:
    Feb 24, 2007
    Posts:
    24
    So is there a way to make a highscore table local to the mahine the game is running to, i.e. offline?
     
  6. MatthewW

    MatthewW

    Joined:
    Nov 30, 2006
    Posts:
    1,356
    For an offline standalone player you could simply use file reading/writing.

    For localized web player scores you could do an all-cookie solution or simply create and store a unique ID for that user for a database solution (benefit there is it would be easy to toggle between global scores and local scores).
     
  7. spazy_t

    spazy_t

    Joined:
    Feb 24, 2007
    Posts:
    24
    Ok, so for the file reading/writing, is there any documentation, or does anyone know how to use it for the purposes of a highscore table?
     
  8. bronxbomber92

    bronxbomber92

    Joined:
    Nov 11, 2006
    Posts:
    888
  9. spazy_t

    spazy_t

    Joined:
    Feb 24, 2007
    Posts:
    24
    ok, erm, i dont spose someone knows or has a tutorial of some kind that could guide me to making an offline highscore table, local to the computer it is playing on.

    Big ask i know, but i just wouldn't know what to do with the mono libraries. Sorry.
     
  10. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    System.IO is disabled in the web player for security reasons. (Wouldn't want some random website writing/reading your files!) The only way to store local data with the Web player is cookies. The link I gave gives pretty darn close to a tutorial. Which problems did you have with it?

    -Jon

    edit: If you don't care about the web player, you can use PlayerPrefs:
    http://unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
     
  11. spazy_t

    spazy_t

    Joined:
    Feb 24, 2007
    Posts:
    24
    Erm, i just had problems understanding what to do with the information from the previous link, but this one seems to make more sense. It's just that my project won't be online, so i need a highscore table that works purely on the computer it is played on. I'll give the player preferences a go, but how would i go about storing the prefrences to a file that would kepp the information when the application is quit, and then still in place when loaded up again?

    Sorry for the enormity of questions, im just having trouble with this one in particular, and im quite keen on understanding how to do it.

    Cheers again.
     
  12. Bampf

    Bampf

    Joined:
    Oct 21, 2005
    Posts:
    369
    Player preferences do that.

    You don't choose what file the stuff gets written into, though. They get written into a .plist file specific to that user and that application. This is usually what you want though. The next time that user runs your program, when the code reads back from the preferences it will see the values that were written.