- Home /
How to wait for callback in OnApplicationPause on android
I am using play-games-plugin-for-unity to save and load data to google play services cloud (Great plugin btw!). This all works well when I use the exit button in my game, and continue playing after this.
What I want to achieve is saving data on "OnApplicationPause" so that when a player minimizes the game and forgets it (or minimizes, kills, and restarts) he/she does not start back at the last "save point".
The problem is that to save the data the play-games-plugin uses a callback:
((PlayGamesPlatform) Social.Active).UpdateState(slot, mySaveState, this);
will call:
public void OnStateSaved(bool success, int slot);
When it is done. But the game has already minimized and stopped processing by the time the UpdateState finishes.
I have tried to use System.Threading.Autoresetevent but this does not work. I was also looking at normal threading, but found many warnings about Unity not being thread safe so didn't continue on that road.
How can I make the game wait for this finished signal before minimizing (or save the data in the background?)
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Can't start a Handler on the main thread 1 Answer
C# How to wait on callback, should I use threading? 1 Answer
Distribute terrain in zones 3 Answers
Photon refusing connection on Android 0 Answers