将游戏保存或加载到Unity GooglePlayServices Cloud会返回InternalError

时间:2019-06-21 22:21:07

标签: c# unity3d google-play-games

我可以登录并打开排行榜,但是云存储和加载SavedGameRequestStatus会以SaveGameOpened方法返回InternalError。
我正在使用最新版本的PlayGameServices。我启用了在控制台中保存游戏的功能。

void AuthenticateUser()
{
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
        .EnableSavedGames().Build();
    PlayGamesPlatform.DebugLogEnabled = false;
    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.Activate();
}

void OpenSave(bool saving)
{
    Debug.Log("Open Save");
    if (Social.localUser.authenticated)
    {
        issaving = saving;
        ((PlayGamesPlatform)Social.Active).SavedGame.OpenWithAutomaticConflictResolution(
            saveName,
            DataSource.ReadCacheOrNetwork,ConflictResolutionStrategy.UseLongestPlaytime,
            SaveGameOpened
        );
    }
}

void SaveGameOpened(SavedGameRequestStatus status, ISavedGameMetadata meta)
{
    Debug.Log("SaveGameOpened");
    if (status == SavedGameRequestStatus.Success)
    {
        if (issaving) //write
        {
            byte[] data = System.Text.ASCIIEncoding.ASCII.GetBytes("test data");
            SavedGameMetadataUpdate update = new SavedGameMetadataUpdate.Builder()
                .WithUpdatedDescription("saved at" + DateTime.Now.ToString()).Build();
            ((PlayGamesPlatform)Social.Active).SavedGame
                .CommitUpdate(meta,update,data,SaveUpdate);
        }
        else // read
        {
            ((PlayGamesPlatform)Social.Active).SavedGame.ReadBinaryData(meta, SaveRead);
        }
    }
    else
    {
        Debug.Log("SaveGameOpened Error Status = " + status);
    }
}

0 个答案:

没有答案