- Home /
Loading a save/playerprefs from a different game?
If I wanted to make 2 games which interact with each other and can load each other's saves, or for example, a sequel of a game that can load the saved file/playerprefs from the first game in the series, what would be the best way for doing this?
I'd be looking at Android as the platform (not sure if it matters, but I thought it'd be best to mention it).
Also, I'd rather not use an xml file, since an xml file can very easily be read and edited.
"there's an asset for that" now
http://answers.unity3d.com/questions/156531/is-playerprefs-secure.html
As I say there in the long comment, "Annoyingly (amazingly) there is no common library or code kicking around to do this."
PlayerPrefs is 100% not-secure.
It cannot be used for any real-world projects.
"Pref hackerz" are ubiquitous. For any popular iPad game, just google for videos showing you how to trivially adjust your score, etc. A preference file is nothing more than "a text file" .... it is completely trivial to "hack" it.
So you have to encrypt your preferences.
Annoyingly (amazingly) there is no common library or code kicking around to do this.
Happily, I've just noticed a package in the asset store where someone bothered to do this and make it a package in the Asset Store ....
http://forum.unity3d.com/threads/157606-Secured-PlayerPrefs-Release
Otherwise you will have to write your own or wait until someone smart puts up an open source one, or other Asset Store products.
It's a really strange issue because un-encrypted preferences are a non-starter. All real money-making games published with Unity will need encrypted prefs.
So it's weird that there isn't dozens of paid solutions for this, and open source packages everywhere, etc etc!!
The young man appeared to also incorporate Eric5h5's essential "ArrayPrefs2" in to his package (note Baroni's comment on that forum page)
you have to encrypt player prefs, and indeed encrypt any supporting incidental text files (say, level descriptions, whatever). It's really amazing this is not the "most common thing in the asset store" or that Unity don't just do it.
Ok, let's say I find a way to encrypt the playerprefs. $$anonymous$$y question, though, remains: how can I make it so "game 2" loads the playerprefs from "game 1"?
Answer by whydoidoit · May 03, 2013 at 06:55 AM
Have you looked at PlayerPrefs????? That can easily be edited. How about a binary file (see this Unity Gems article). You could also encrypt it by a real method like those available from http://msdn.microsoft.com/en-us/library/0ss79b2x(v=vs.85).aspx or just Xor each byte with a value to put off casual hackers.
Thank you for the link. So, what do you think is the best way to do it? To make the first game save a binary file and the second game just load it?
I was thinking about playerprefs since they are always saved in a specific location, and I would want the second game to load them automatically (without asking for the player to find the save file of the first game). Any suggestions on that?
But anyway, even if I end up using the binary file... For curiosity's sake, is it possible to load a different game's playerprefs?
the simple answer is you can't -- you do it via the cloud and user accounts
surely everyone knows this now? it's not 1960 eh ?
obviously iPhones completely lock up individual apps and they can't communicate. it's a basic of computing for five computing years (that's 18,000 dog years)
in iOS you can share the first-two-parts-or-something of the app id btu nobody does that or knows anything about it, it'll never happen
you're right sorry I misunderstood your question at first
I just assumed you meant from a NEW RELEASE, NEW VERSION of the same game, sorry
you can't share anything between iPhone apps, no
so if you want to do this, have user accounts on your server ...
I don't think you can really load the prefs from another game - there appears to be no function to open prefs.
Yes so I'd save a binary file either locally or on a server and then open it - not sure what your file restrictions are on Droid - but read should be possible.
I'm presu$$anonymous$$g your app is installed in a well known location so you should be able to find it without browsing. The best option might be a server though, just upload the data to some cloud server and pull it back down. Then you could do it based on the $$anonymous$$AC address of the phone (but of course you would require a data connection).
As @Fattie says, the only way on iOS would be the cloud.
Isn't it possible to store files in a common user-place on iOS? For example for storing screenshots etc. I don't think that you can even read the PlayerPrefs of another game since they are stored in the internal storage. It's possible, but only with a rooted device (i can only speak for Android since i haven't tested much on iOS ;))
Answer by DaveA · May 03, 2013 at 07:43 AM
Back to the question: On Windows at least I know you can access the Registry directly, so it's easy to get at anything, and that's where the PlayerPrefs are for Windows. Don't know how easy it is to get at other platforms, don't imagine it's terribly hard. Just find the file.
Your answer
![](https://koobas.hobune.stream/wayback/20220613101441im_/https://answers.unity.com/themes/thub/images/avi.jpg)