Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Saving game and loading it.

Discussion in 'Editor & General Support' started by User340, Feb 14, 2008.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    How would you save a game progress level and read it onto someone's hard drive. (With a web game and a standalone game)
     
  2. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    First, you can't in the webplayer unless you can crunch it all into a cookie (bad idea), or store it on a webserver (painful).

    As for standalone, you have the full .NET framework at your mercy. You can write a simple binary file, or go for full XML if you like. (better idea).

    There's a catch, to save a large amount of data, or complex relationships means a lot of carefully designed code.

    If you just want to store what level the player has reached, their health, score and a few other basic variables then I recommend Unity's PlayerPrefs class instead. It won't work in the webplayer either.

    http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.html

    To write a basic text file, google FileInfo and StreamWriter.

    -Jeremy
     
  3. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Thank you, it works perfectly :). I never knew that PlayerPrefs writes info to their computer.