how to Securely write saved data in unity game

Viewed 24

I try to make savefile as follows;

string savedata ="aaaa"; //crypted string       
StreamWriter writer = new StreamWriter(Path, false);
writer.WriteLine(savedata);           
writer.Flush();           
writer.Close();

But in this way ,if you exit the application before the writing is finished, you may not be able to save the file.

How can we address this issue?

1 Answers

If i understand right, maybe you could make the save in the "OnApplicationQuit()". I think even if the user decide to leave unity will execute this function and wait for it to finish. So your game will be saved anyway and you don't have to change your code much.

Related