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.

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.

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.