- Home /
Answer by Kos-Dvornik · Feb 18, 2016 at 11:32 AM
You 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. http://kostiantyn-dvornik.blogspot.com/2016/02/skyship-aurora-store-data-tutorial.html
Answer by Cherno · Apr 16, 2015 at 06:34 AM
To learn how to serialize data and write it to a file, search for BinaryFormatter. It's rather simple, don't worry.
I had used BinaryFormatter, it's saved in Application.persistentDataPath. It still deleted when it uninstalled.
Well, 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.
Which location should be used? is there some variable Application.persistentDataPath to hold it? This is for mobile development (Android, IOS, Windows Phone)
I have no expeirence with saving data on $$anonymous$$obile ports, I don't even know if System.IO is available for that kind of build (it isn't for Web player, for example).
Answer by KdRWaylander · Apr 16, 2015 at 06:50 AM
Hi,
http://docs.unity3d.com/ScriptReference/PlayerPrefs.html
or http://docs.unity3d.com/ScriptReference/Windows.File.html
PlayerPrefs store to the registry, are they kept when the application is uninstalled?
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
I had also used pleyerfreb, but it still deleted when uninstaled
Answer by Sarthak123 · Apr 20, 2015 at 11:37 AM
If 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)?
For 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, ins$$anonymous$$d 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
I had also used pleyerfreb, but it still deleted when uninstaled
hmm... it's expected, as playerprefs saves to the default location i think, which in case in in the internal memory of mobile, so unistalling will delete the data, but in this case, i think there are 2 ways -
As i already suggested, you can store data on SD Card, but every mobile does not support SD Card, so there's a chance your game will not be playable on every device.
I have never worked with android game development, so i can't tell but if you working on android platform, then i have seen that game store there data on Google Play account. But i am not sure if the similar feauture is available for Windows and IOS devices.
Answer by screenname_taken · Apr 20, 2015 at 07:59 PM
If 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.