Questions concerning saving and loading data with tutorial code.
I can't help but notice that the way he saves is incomplete. What i mean is that, he doesn't explain how he can set the code up for the save_game function not to create the save file every time it is called and instead check if the file exists and then write data in it. Secondly, what if you want to save only a few data each time and not everything?
the code was like this :
BinaryFormatter bf = new BinaryFormatter ();
FileStream file = File.Create (Application.persistentDataPath + "/stateInfo.dat");
SavedData data = new SavedData ();
//put stuff in data here.
bf.Serialize (file, data);
file.Close ();
my question is: I check if the file exists, and then what do i write instead of:
FileStream file = File.Create (Application.persistentDataPath + "/stateInfo.dat");
SavedData data = new SavedData ();
so i can save the variables in data without creating the file again?
Also is it possible to save only a few of those variables instead of everything?
Your answer
Follow this Question
Related Questions
How to save my gold when i quit the game 1 Answer
Why Does My Saved Data Not Load? 0 Answers
PlayerPrefs Autosave [SOLVED] 2 Answers
Same Guid for same prefab 0 Answers
why am I losing player.transform position in saved game when I change levels 1 Answer