简体   繁体   中英

Unity Google Play Saved Games

I have been trying to implement google play saved games to my game in Unity3D using the official plugin . I want to save few variables like User highscore and the number of coins user has. PlayerPrefs won't suffice as the data will get wiped out once the user uninstalls game for any reason. I have been looking out for tutorial on this for quite some time but in vain. I have been through Unity serialization and de-serialization stuff. So if anyone can help me out with saving and retrieving variables from google play saved games. I have been through the documentation but I cannot understand much from it and yeah I am using C#. Thanks

Have you read this , its pretty self-explanatory.

Updating with code snippets :

To Init Google play :

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();

To sign in(call this in a Start(), after you have activated the platform) :

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

From here on please read the documentation detailing how to read and write save games to the cloud. That part can be found here . Read the code and adapt it to your specific use case. I cant write it for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM