is there a way to save data on Android before quit?
Hey, i have a way to save the data of an android game. Now i dont want to Save the Data manually with a button, i want to always save the data before the User quits the Application. I though "OnApplicationQuit()" would do that work for me, but it doesnt.
Why not just save the data after it is updated? Especially in the case of a crash, this would help keep all the data from that play session from being lost.
because this would be a bit too much. I make an automatic save every $$anonymous$$ute and at crucial moments.
Answer by Inder8288 · Sep 28, 2018 at 12:03 PM
You can check in update that if player pressed the escape button? if he does, you can call save function, and after saving all data(Like with PlayerPrefs), Call Application.Quit at last of the save function, maybe like this:
void Update(){
if(Input.GetKey(Keycode.Escape){
SaveData();
}
}
void SaveData(){
----
save data logic
---
Application.Quit();
}
Your answer
Follow this Question
Related Questions
Can this script be better optimized? 1 Answer
Code not working as it should 1 Answer
Help with C# code + Unity 1 Answer
Problem with inventory asset's script and its working 0 Answers
Running C# Function from JS file 0 Answers