Google Play Games Service

So I finally got GPG(Google Play Games) in my current 2D game I’m developing.
Only thing I’m currently confused about, is implementing the Save-Load game features.
I’m beyond lost, how you actually call the Save and Load Games methods.
If anyone can help, that’d be greatly appreciated!

  void SaveGame (ISavedGameMetadata game, byte[] savedData, TimeSpan totalPlaytime) {
        ISavedGameClient savedGameClient = PlayGamesPlatform.Instance.SavedGame;

        SavedGameMetadataUpdate.Builder builder = new SavedGameMetadataUpdate.Builder();
        builder = builder
            .WithUpdatedPlayedTime(totalPlaytime)
            .WithUpdatedDescription("Saved game at " + DateTime.Now());
        if (savedImage != null) {
            // This assumes that savedImage is an instance of Texture2D
            // and that you have already called a function equivalent to
            // getScreenshot() to set savedImage
            // NOTE: see sample definition of getScreenshot() method below
            byte[] pngData = savedImage.EncodeToPNG();
            builder = builder.WithUpdatedPngCoverImage(pngData);
        }
        SavedGameMetadataUpdate updatedMetadata = builder.Build();
        savedGameClient.CommitUpdate(game, updatedMetadata, savedData, OnSavedGameWritten);
    }

    public void OnSavedGameWritten (SavedGameRequestStatus status, ISavedGameMetadata game) {
        if (status == SavedGameRequestStatus.Success) {
            // handle reading or writing of saved game.
        } else {
            // handle error
        }
    }

    public Texture2D getScreenshot() {
        // Create a 2D texture that is 1024x700 pixels from which the PNG will be
        // extracted
        Texture2D screenShot = new Texture2D(1024, 700);

        // Takes the screenshot from top left hand corner of screen and maps to top
        // left hand corner of screenShot texture
        screenShot.ReadPixels(
            new Rect(0, 0, Screen.width, (Screen.width/1024)*700), 0, 0);
        return screenShot;
    }

The documentation can be found at GitHub - playgameservices/play-games-plugin-for-unity: Google Play Games plugin for Unity

Save your game info into a Hashtable like this… We did something like this in a project.

var tbl = new Hashtable();
tbl.Add(“CurrentLevel”, game.GetCurrentLevel());
tbl.Add(“Inventory”, game.GetIventoryAsArrayList() );
tbl.Add( “HowManyPointsIHadLastTimeIPlayed”, game.GetEarlierPoints() );
tbl.Add(“PlayerPosXYZ”, game.GetPlayerPosAsCommaSepString() );

Then serialize the Hastable into JSON.

var stringJSON = MiniJSON.serializeObject( tbl );

var save_game_bytes = System.Text.UTF8Encoding.UTF8.GetBytes( stringJSON );

Then when you’re saving the game :
gservmgr.SaveGame( game.CreateSaveGameMeta(), save_game_bytes, game.GetTotalPlayTime() );