I am having trouble saving my game on iphone. I have managed to achieve this on Unity but not unity iphone. Everything about the code I have is the same apart from the buttons, which have gone from click to touch. I have tested the buttons and they work fine with other code. My only thoughts are that Playerprefs run differently on the iphone, is this true?
no idea how high it is but I know that once you cross the border it will crash the app on a regular base …
found that out the hard way in a pure objc application.
its intend is to be used for preferences and alike.
for savegames you should consider using System.IO (file stuff) and the Cache folder of your iphone application
Hi, thanks for the reply. I am still unsure what to do about the script. I have set a var LevelNum to each level and have set it to the Playerprefs when a button is pressed.
I then use this code to get back to the level. I get no errors but nothing seems to work. This method is the one that works on Unity.
var holder2 : int = PlayerPrefs.GetInt("levelNum", -1);
the -1 in the function there is so you know when the key was not present, that code is technically correct.
What is technically only half as correct at least at the time is that OS 4 or 4.0.1 somewhere seems to have messed something below the surface and as a consequence it seems like the prefs don’t survive the end of application. Thats at least what threads here implied.
If you have a simple sample showing it, make sure to report it through the bug reporter
hmmmmm does this mean I would need to avoid Playerpref to save on the iphone. This code works fine on Unity (PC Version). Would you recommend another way of saving to an iphone? I just wanted a simple save/ continue feature.
Not necessarily, although it has been temperamental. How do the editor and .app communicate to each other? Is there a separate .plist file for the editor? When I’ve had problems with PlayerPrefs it seems like theres no definite way to see if the iPhone/iPod is in charge of the .plist data. Maybe this is where it goes a bit wrong. I’ve been able to build to iphone, and the plist data is still there from previous plays.