Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Saving data to permanent storage

Discussion in 'Scripting' started by disband85, Jan 25, 2011.

  1. disband85

    disband85

    Joined:
    Dec 7, 2010
    Posts:
    83
    What's the best way to save high scores and other accumulative data on an iphone? Writing to a text file seems rather primitive, are there better ways of doing it?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    PlayerPrefs.

    --Eric
     
  3. disband85

    disband85

    Joined:
    Dec 7, 2010
    Posts:
    83
    Thanks :D

    Just read up on PlayerPrefs, sometimes Unity just makes it too easy >_>

    Just to clarify....

    Code (csharp):
    1.  
    2. PlayerPrefs.SetInt("TimesPlayed", 5);
    3.  
    If the key "TimesPlayed" doesn't exist, it creates it?

    Also, I read I should encrypt and decrypt the data because apparently leaderboards get hacked easily? (Yes I will mostly be using PlayerPrefs for open feint leader boards and achievements)
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Yep.

    Depends; it's not possible to hack them unless the device is jailbroken.

    --Eric