【问题标题】:Saving to Google Play Cloud Save Automatically自动保存到 Google Play 云保存
【发布时间】:2015-08-22 02:45:19
【问题描述】:

背景
我正在处理已在 Google Play 商店上发布的 android game
现在我计划添加云保存功能作为更新。
(仅供参考:我使用的是 Unity 和 Play Games plugin

问题
经过数小时的研究和实验,我目前正纠结于如何自动保存游戏。

我的游戏是一系列迷你游戏,玩家可以在其中继续玩直到他的生命耗尽。
我希望在玩家输掉比赛时自动进行保存。

根据插件,我是这样保存到云端的:

public void SaveGame (ISavedGameMetadata game, byte[] savedData) {
    /* code omitted */
    savedGameClient.CommitUpdate(game, updatedMetadata, savedData, OnSavedGameWritten);
}

函数SaveGame需要2个参数,第一个是元数据,第二个是数据本身。

在我搜索的所有地方(甚至在 Google 中),我都找不到自动生成元数据的方法。
根据我的研究,我可以从以下函数中获取元数据:

void ShowSelectUI() {
    uint maxNumToDisplay = 5;
    bool allowCreateNew = true;
    bool allowDelete = true;

    // I will need to call this function first
    // This will display a dialog to the player
    // The player will need to create a new save manually afterwards
    ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
    savedGameClient.ShowSelectSavedGameUI("Select saved game",
                                          maxNumToDisplay,
                                          allowCreateNew,
                                          allowDelete,
                                          OnSavedGameSelected);
}


public void OnSavedGameSelected (SelectUIStatus status, ISavedGameMetadata game) {
    // And then from the callback function I get the meta data
    // (ISavedGameMetadata game)

    if (status == SelectUIStatus.SavedGameSelected) {
        // handle selected game save
    } else {
        // handle cancel or error
    }
}

这样用户需要打开一个对话框,然后自己创建一个新的存档。
这不可能在我的游戏中发生,因为每次玩家输球时我都需要保存。

参考
我知道这应该是可能的,一个名为Get Bigger! Mola 的游戏可以在玩家每次输掉时保存进度而不打开保存对话框。

问题
谁能给我任何关于这个的线索?
我花了一整天的时间寻找答案...
任何形式的帮助将不胜感激。

【问题讨论】:

  • 你想明白了吗?我有同样的问题。我很肯定一定有办法做到这一点,因为很多游戏都允许基于谷歌帐户进行云保存,但我似乎找不到任何关于该主题的内容。

标签: android unity3d google-play-games google-cloud-save


【解决方案1】:

here所述,您可以打开一个新快照,而无需从列表中选择一个,只需指定文件名,如果存在,它将使用它,否则将创建一个新的。

类似这样的:

        ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;
    savedGameClient.OpenWithAutomaticConflictResolution(filename, DataSource.ReadCacheOrNetwork,
        ConflictResolutionStrategy.UseLongestPlaytime, delegate(SavedGameRequestStatus status, ISavedGameMetadata metadata) {
            // your code here ....
        });

【讨论】:

    【解决方案2】:

    我个人不熟悉您尝试保存统计信息的资产。 但是,我确实使用了我个人可以推荐的资产Stan's Native

    如果您想要其他免费的东西,有这些链接,Search Native

    无论如何,您应该查看有关使用 theie 云的 Google 教程,Android 网站上有很多不涉及 Unity 的信息。 Android Developer

    【讨论】:

      猜你喜欢
      • 2018-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多