- Home /
Scriptableobject not saving if i force close the application.
Actually right now there is no exit function in my game and i have saved most of my data in scriptable objects since i force close the app it is not saving everytime i force close the game. Is there anyway to save even if i force close the app. The app is right now in android. But when i port my game to iphone there wont be an exit function at all. So it won't save at all if it keeps going on like this. Someone pls help me with this soon. Thanks in advance.
Have you tried the OnApplicationQuit() funtion provided by unity.Just put this function in your code and it will be called whenever the application closes.
void OnApplicationQuit()
{
//Do your task here
}
Answer by liortal · Aug 06, 2014 at 05:59 PM
There's nothing you can do when the user forcefully closes your game.
Same thing about the battery running out, or the phone getting smashed to pieces by a train.
It won't call any nice callback in any of these scenarios.
What you should do is store the data persistently at certain key points in the game (up to you).
You are right if playerprefs there is a function called save to save them. But for scriptable objects is there any such function to save them like it is getting saved on the exit of the app.