Hey there! Thanks for the reply, just tonight I managed to get everything working in sync.
I still don't quite get it but, the byte arrays and the regular ES3.Save seem to do the same thing? Once I take a file saved with ES3.Save and load it as an array (ES3.LoadRawBytes), feed it to the Google Play Saved Game API, then retrieve it and open it locally (by overwriting the current local save file with the cloud one), it works all the same. I'm able to use ES3.Load<int>("key", "filePath") on the byte array and it works all the same. Maybe it is due to my ignorance of how serialization and byte arrays work, but it seems to work. My current setup is as follows:
Code: Select all
if (endScore >= 0.25f && endScore <= 0.5f)
{
Debug.Log("Save 1 star");
int unlockedLevels = gameManager.currentScene;
int currentUnlockedLevels = ES3.Load<int>("unlockedLevels", "playerData");
if (currentUnlockedLevels < gameManager.currentScene)
{
ES3.Save<int>("unlockedLevels", unlockedLevels, "playerData");
ES3.Save<int>("Highscore" + gameManager.currentScene, endScoreInt, "playerData");
}
}
//repeat to check score ranges
byte[] savedGame = ES3.LoadRawBytes("playerData");
gameManager.WriteSavedGame(gameManager.mySavedGame, savedGame);
gameManager.ResetScore();
Here, based on player score I increased the unlocked levels by one if conditions are met and save the star amount based on score. Then when the if statements are done, it converts the entire playerData file into a byte array and calls the function to commit the save to the cloud. Now, upon reading a cloud save, I use Easy Save 3 to overwrite the current local file and start using that for all values with:
Code: Select all
if (data.Length > 0)
{
byte[] loadedSave = data;
ES3.SaveRaw(loadedSave, "playerData"); //Overwrite current local data to be used.
}
Now I can use ES3.Load on that byte array as if it were a regular ES3.Save file. In fact, both the LoadRawBytes and ES3.Save yield the exact same file. Maybe I'm completely oblivious to how it all works internally, but it just seems to work perfectly. I was under the impression that ES3.Load could not read from a byte array, but it can (as you pointed out). Am I incorrect in any of these assumptions? Thanks!
PS: Pardon if it sounds all too noobish, I started programming and learning C# 2 weeks ago so a lot of these concepts fly over my head.