2015-07-21 163 views
0

我一直在尝试使用官方plugin在Unity3D中将我的游戏保存到我的游戏中。我想保存一些变量,比如User highscore和用户拥有的硬币数量。 PlayerPrefs是不够的,因为一旦用户由于任何原因卸载游戏,数据将被清除。 我一直在寻找这方面的教程很长一段时间,但徒劳无功。 我已经通过Unity序列化和反序列化的东西。因此,如果任何人都可以帮助我保存和检索从谷歌播放保存的游戏变量。 我已经通过文档,但我不明白从它,是的,我使用的是C#。 谢谢Unity Google Play已保存的游戏

回答

0

你看过this,它很好理解。

更新的代码片段:

至Init,谷歌播放:

using GooglePlayGames; 
    using GooglePlayGames.BasicApi; 
    using UnityEngine.SocialPlatforms; 

    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() 
     // enables saving game progress. 
     .EnableSavedGames() 

     .Build(); 

    PlayGamesPlatform.InitializeInstance(config); 
    // recommended for debugging: 
    PlayGamesPlatform.DebugLogEnabled = true; 
    // Activate the Google Play Games platform 
    PlayGamesPlatform.Activate(); 

要登录(在开始(这个),您已经激活了平台后):

Social.localUser.Authenticate((bool success) => { 
     // handle success or failure 
    }); 

从这里开始,请阅读详细说明如何读取和写入保存游戏到云中的文档。该部分可以找到here。阅读代码并根据您的具体使用情况进行调整。我不能为你写。

+0

我已经通过文档,但我不想显示加载游戏画面。我想要的是以下工作流程: - 1.用户开始游戏。 2.自动谷歌玩游戏登录。3.自动加载用户拥有的硬币数量和他的高分。 4.在游戏结束后,自动保存硬币数量和高分。 – Saurabh

+0

@Saurabh我编辑了我的答案,以帮助您更好地理解。您需要的所有代码都在文档中。 –

相关问题