Hello All,
I wanna ask, How to save data for my game which is not deleted when it’s uninstalled?
5 Answers
5You can use this tutorial for creating custom save file or saving into player prefs. Here you will find sources compitable with XBox One as well.
To learn how to serialize data and write it to a file, search for BinaryFormatter. It’s rather simple, don’t worry.
Hi,
That's a good question, i never went that far with playerprefs :o EDIT: but if you mean when you quit and come back on the game, yes it does keep the values
– KdRWaylanderIf you are saying about your game save files, then i would prefer it to save on an drive other than C:\ such as D:\
if you are using unity’s default save file loc. then drop it and use your custom according to your need. I don’t work much with save files and serialization and all so i can’t tell much, but as a simple example -
import System;
import System.IO;
function name()
{
System.IO.File.WriteAllText("D:\Saves\MyGame\savfile.extension", "Data");
}
This might do the trick.
Thanks, it's a good idea. Define the directory directly But how can i define the directory path? Especialy for mobile (android, ios, and windows phone)?
– leopriposFor Pc, the above method works... i dont have any exp. with mobiles, so i cant exactly tell, but, for mobiles, i think there are no drives in mobile, andorid, IOS, windows. But, instead of saving into internal memory, maybe you can try saving it in SD Card. I am not sure if it's possible or not. Here this might help.. http://answers.unity3d.com/questions/162211/how-to-saveload-game-on-mobileandroid.html
– Sarthak123If it’s for mobile, you may want to check into uploading stuff to Play.
For example Metal Slug Defense on android is storing saved game data to Play/your account and you can retrieve it on a different device to keep on playing from where you left off.
I had used BinaryFormatter, it's saved in Application.persistentDataPath. It still deleted when it uninstalled.
– leopriposWell, why do you save to Application.persistentDataPath then? :) Just give it any other directory on your hard disk :) The Application.persistentDataPath is just a string.
– ChernoWhich location should be used? is there some variable Application.persistentDataPath to hold it? This is for mobile development (Android, IOS, Windows Phone)
– leopriposI have no expeirence with saving data on Mobile ports, I don't even know if System.IO is available for that kind of build (it isn't for Web player, for example).
– Cherno