Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

save and load script.

Discussion in 'Scripting' started by tuliocll, Oct 24, 2011.

  1. tuliocll

    tuliocll

    Joined:
    Oct 24, 2011
    Posts:
    89
    Hello, first of all I am Brazilian and I'm using google translator. I wonder if any man knows how to make a save and load. Thank you.
     
  2. nazgul

    nazgul

    Joined:
    Oct 24, 2011
    Posts:
    10
  3. tuliocll

    tuliocll

    Joined:
    Oct 24, 2011
    Posts:
    89
    hello Nazgul, could give an example of how to use? I'm too young!
    Thank you.
     
  4. bigmisterb

    bigmisterb

    Joined:
    Nov 6, 2010
    Posts:
    4,221
    Code (csharp):
    1.  
    2. //Save:
    3. PlayerPrefs.SetInt("MyStat", 1);
    4. PlayerPrefs.SetString("MyName", "Bob");
    5. PlayerPrefs.SetFloat("MyHeight", 85.5);
    6.  
    7.  
    8. //Load:
    9. var myStat = PlayerPrefs.GetInt("MyStat");
    10. var myName = PlayerPrefs.GetString("MyName");
    11. var myHeight = PlayerPrefs.GetFloat("MyHeight");
    12.  
     
  5. Disati

    Disati

    Joined:
    Oct 5, 2009
    Posts:
    111
    Oh you Google Translate...

    Will the Unity player load the save game automatically? Or will the player have to "browse" for its directory?
     
  6. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    There is no directory if you use playerprefs. The 'browsing' or how you handle it is completely up to you.
    Unity has no builtin savegame functionality as that completely depends on the game on what and when it wants to save and restore data

    The simplest to get there is Bradys / Above Beyond Softwares EZGameSave
     
  7. tuliocll

    tuliocll

    Joined:
    Oct 24, 2011
    Posts:
    89
    OK thank you, BigMisterB, Disati and dreamora. I create unity tutorials in Portuguese, any time I post in English. Look at this:
    (Comprar is Buy in Portuguese)
    http://twitpic.com/77kycq

    ......