Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by MikezNesh · Aug 04, 2011 at 09:41 PM · iphoneplayerprefsachievement

Achievements with PlayerPrefs...

I want to make my own mini achievement system. I was just wondering if it would be valid to use PlayerPrefs to do so. Has anyone done something like this? Or should I use a text file like I read about somewhere? (This is for an iPhone App btw)

My plan is to just use an if statement to check if you achieved something and then if so save it to PlayerPrefs as true. Then in the achievements scene, check to see if the achievements are marked true and light those trophies up.

Just to clarify, I know how to code it, just wondering if this method would work well or if there is any better method.

Thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by getluky · Aug 04, 2011 at 09:46 PM

I would recommend writing out text files instead of using PlayerPrefs, especially as you start storing larger amounts of data. Stability was an issue for me a year ago when over-using PlayerPrefs for persistent game save data, achievements, etc. and I ended up writing a FIle IO layer that handled serialization and validation of hashtables, string arrays, etc. It worked much better, and now that Android gives you back a persistentDataPath, can work basically with the same C# code without having to delve into Java.

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MikezNesh · Aug 04, 2011 at 10:04 PM 0
Share

Could you give me some pointers on how to set my game to save and retrieve data to/from a text file? I don't have much experience there. Thanks again.

avatar image getluky · Aug 04, 2011 at 10:37 PM 0
Share

This script from Unifycommunity looks like it might help. Have a look:

http://www.unifycommunity.com/wiki/index.php?title=SimpleDictionary

avatar image MikezNesh · Aug 05, 2011 at 12:09 AM 0
Share

hmmmm ok. I'll try this out. Also, how much do you think is too much for PlayerPrefs? If I don't get a good grasp of txt files I will probably store highscores, number of gems, and achievements (about 10). Do you think that is too much?

avatar image Waz · Aug 05, 2011 at 12:13 AM 0
Share

If there are stability bugs with PlayerPrefs, lots of people would like to know concretely. Your answer is basically "don't use PlayerPrefs for anything".

PlayerPrefs has a 1$$anonymous$$B limit on WebPlayer (not sure on iOS), so if you went over that, you would have gotten problems.

avatar image Waz · Aug 05, 2011 at 12:59 AM 0
Share

A few highscores and counts is a tiny amount (probably about 1 $$anonymous$$B in total). It will be no problem at all for PlayerPrefs.

Show more comments
avatar image
2

Answer by Waz · Aug 05, 2011 at 12:29 AM

PlayerPrefs is the perfect choice for what you are doing, provided you keep below the size limit (1MB on WebPlayer, not sure on iOS). Note that this limit includes all past keys, so if you do something like:

 PlayerPrefs.SetString(Time.time.ToString(),"Waste Memory");

Then you'll quickly fill it up. More concretely, if you store game save files and don't delete old save keys, you will run into problems.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image MikezNesh · Aug 05, 2011 at 01:48 AM 0
Share

thanks. How could I find a definite amount of how much PlayerPrefs space I'm using? The edit log?

avatar image Daniel G · Jul 22, 2013 at 03:47 PM 0
Share

@Waz im wondering the same thing, is there a way to VEIW how much space you are using at any given time, AND is there a way to FLUSH or Delete OLD keys? Do you have an example?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

PlayerPrefs aren't working in iphone 2 Answers

Is "PlayerPrefs" (Get/Set) slow ? 2 Answers

iphone PlayerPrefs 4 Answers

Where on iPhone editor are playerprefs stored. 1 Answer

Is there a useful upper limit to the size of ArrayPrefs (PlayerPrefs) data? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges