play-games-plugin-for-unity
play-games-plugin-for-unity copied to clipboard
Unity's Google Play Game Services(GPGS v10.14) ReadBinaryData() does not run in Task.Run()
I am implementing Cloud Save and Load function by linking Unity and Google Play Game Services (GPGS v10.14).
I need to load data from the cloud and process the loaded data into strings. At this time, I used async-await to process it asynchronously because the order is important.
private async void OnLoadData(ISavedGameMetadata metadata)
{
var savedGame = PlayGamesPlatform.Instance.SavedGame;
var task = Task.Run(() => savedGame.ReadBinaryData(metadata, OnReadBinaryDataRequestHandler));
await task;
}
private void OnReadBinaryDataRequestHandler(SavedGameRequestStatus status, byte[] loadedData)
{
}
However, when I call ReadBianryData()
with Task.Run()
, the program terminates. (Testing results on Galaxy S10 5G)
Why is the program terminated?
I believe you have to call this API only from the main thread.