Google Play Games Integration
This integration provides storage function for Google Play Games Saved Game feature that allows you to save / load data into the player's google play account.
By using this approach, you save on cloud hosting costs and keep the data safe while the user has the ability to change devices without losing their progress.
Getting Started
- Download and Install Google Play Games plugin for Unity
- Download and Install Google Play Games Integration for Save System
- (Deprecated) This initialization part was necessary prior to Sign-in v2 of Google Play Games plugin, now you can skip this step, Initialize Google Play Games platform:
var builder = new PlayGamesClientConfiguration.Builder();
builder.EnableSavedGames();
builder.AddOauthScope("profile");
var config = builder.Build();
PlayGamesPlatform.InitializeInstance(config);
// Enable debug mode as needed
PlayGamesPlatform.DebugLogEnabled = true;
- Then authenticate the User to initialize the storage:
PlayGamesPlatform.Instance.Authenticate(SignInInteractivity.CanPromptOnce, (status) =>
{
if (status == SignInStatus.Success)
{
Debug.Log("Logged in using Google Play successfully!");
// Change the storage to Google Play Saved Game Storage
SaveSystemSettings settings = SaveSystemSettings.DefaultSettings;
var googleStorage = (GooglePlaySavedGameStorage)StorageFactory.FromConnectionString("google-play-games://");
settings.Storage = googleStorage;
// You can update the saved game metadata information through the GooglePlaySavedGameStorage interface through the below properties
//googleStorage.MetadataPngImage;
//googleStorage.MetadataDescriptin;
//googleStorage.MetadataPlayedTime;
}
else
{
Debug.LogError("Failed to login with Google Play");
Debug.LogError(status);
}
});
- Now you can simlpy call the Save System API and the operations will be done on the Saved Game storage.
Example
You can add the example script included in the integration package to any demo scene, and then you can just try out the demo and it'll use the Google Play Games Saved Game storage. Also, consult the example script on how to login and initialize Google Play Games platform.