|
Ok so I've gone over a bunch of different ways of saving a loading a game and none of them have really helped. I have a bunch of player variables (like stats, and items). I do not need to save the player's location, only the stats. With that said, PlayerPrefs were are easy fix, and they work. However, they are extremely easy to open up and change information. Not only that, but is there a way I can change the save location of the PlayerPrefs? If anyone knows how to do this, or has a better idea than using PlayerPrefs to save only variables, that would be greatly appreciated!
(comments are locked)
|
|
Well, I am using C# serialization and it works great. You can save the information as binary and it is not the easiest thing to change. Here is an example that saves two variables, int1 and string1 Yes, it is pretty long, but it is easy to add new variables. Google 'C# serializing' for more information. I've taken a look at that as well, and it seems to be the better option. I'm using javascript so will I need to change anything to make this work? It doesn't interfere with anything other than the variables it's saving right?
Mar 08 '12 at 03:28 PM
BiTT_JL
I don't know about javascript, I generally use C#. I think this is a C# feature... However, you could make a javascript script access this C# script, I think. Javascript example(You need to have the both scripts attached: http://paste.bradleygill.com/index.php?paste_id=358823 For more information, check GameObject.GetComponent from unity script reference And scroll to the bottom
Mar 08 '12 at 08:15 PM
raoz
Thank you for the help! I greatly appreciate it!
Mar 08 '12 at 08:34 PM
BiTT_JL
Could you please then mark it as right ansver?
Mar 08 '12 at 10:14 PM
raoz
I'm a bit late to the party, but this answer works well in conjunction with this page I found searching for Serialization in general. Hope it helps someone else too! http://www.switchonthecode.com/tutorials/csharp-tutorial-serialize-objects-to-a-file
Nov 05 '12 at 09:51 AM
BrigadeJosh
(comments are locked)
|
|
Well, even if you want to save just a few variables of your player, it's an easy task: take a look at this answer of mine, I think that it could help you. And no, you can't change the save location of the PlayerPrefs. The Documentation says where it's located, but it doesn't speak about the possibility of changing the path. You have to use a database or a text file to decide on your own the location. Yes I'm currently using PlayerPrefs, but the bad thing about them is that they are extremely easy to get into and change. I don't want the player to change any of their stats to what they shouldn't be. If there isn't a way I can change the path to it, is there a way I can encrypt or at least make it more difficult to access the data? I just don't want the player altering their level or experience, or the items they have.
Mar 08 '12 at 04:33 AM
BiTT_JL
Well, you could try encrypting the data before you enter it into the playerprefs! That way, the playerprefs file contains an encrypted version of the information, that you decrypt after loading it. If the player tries to modify it, they will destroy all their data unless they have some means of decoding it (which I guess makes them very determined).
Mar 08 '12 at 04:36 AM
syclamoth
(comments are locked)
|

Note - if anyone's still reading this. It looks like there is now a handy package on the AssetStore,
http://forum.unity3d.com/threads/157606-Secured-PlayerPrefs-Release
"Secured PlayerPrefs" -- which is encrypted player prefs. This solves 99% of the problem at hand, hope it helps.