- Home /
Can I transfer the PlayerPrefs.plist file to the iPhone?
I'm not sure if this is possible or not, and maybe there's another way to do this...
I'm saving a bunch of settings to a PlayerPrefs file which I then read on game launch to load default values for different classes.
The problem is that the saved PlayerPrefs file doesn't exist on the iPhone when the game is launched for the first time, so since it can't find those saved values, it uses whatever default values are assigned in the "PlayerPrefs.GetFloat("MyValue", defaultValue)" call.
Is there any way to "transfer" the PlayerPrefs file from the computer to the iPhone when making builds? Am i gonna have to write those values to a text file which I would then access when the game runs?
Thanks for your time! Stephane
why do u want to transfer the plist file.what are default values u are setting set them in the "awake" or the "start" function. so when u load game they will assigs the values.
The reason is I created a EditorGUI tool which lets me change all the default values for my upgrade system, and saves them as the starting values for the class. I wanted to use a GUITool so that I wouldn't have to go inside the class to change them or have the class attached to a GameObject to change them in the editor.
Answer by Graham-Dunnett · May 15, 2013 at 10:35 AM
I don't think that there is a way to do this with player prefs. I think the solution that I'd look into (if faced with the same problem) is to transfer to the phone a text file or xml document with the initial values in. Note that your can mark your application as sharing files with iTunes, so you can copy files to/from the app. Look up UIFileSharingEnabled
to see how to make this change. Then you can drag and drop your text file to the device. Alternatively I think there is something like StreamingAssets folder, which gets copied to the device when you do a build and run. Anyway, once that text document is on the device you can read it and create the player prefs.