Page 1 of 1

Save multiple files in the cloud

Posted: Fri Apr 28, 2023 4:55 pm
by EVG
Good afternoon. When using Easy Save 3, my game uses two different save files, how do I properly save both of them in the Google Play cloud? If there was only one file, it would be possible to simply translate its bytes and save, for example:

Code: Select all

byte[] savedData = ES3.LoadRawBytes();
SaveGame(savedData);
But what if you need to send two different files?

Re: Save multiple files in the cloud

Posted: Sat Apr 29, 2023 7:27 am
by Joel
Hi there,

You use the filePath parameter of ES3.LoadRawBytes to specify which file you wish to upload. If you don't specify the filePath parameter it will get the bytes from the default file.

All the best,
Joel

Re: Save multiple files in the cloud

Posted: Sat Apr 29, 2023 10:41 am
by EVG
Joel wrote: Sat Apr 29, 2023 7:27 am Hi there,

You use the filePath parameter of ES3.LoadRawBytes to specify which file you wish to upload. If you don't specify the filePath parameter it will get the bytes from the default file.

All the best,
Joel
Thanks for the reply, I understand that. But I don't understand how to make two different files into one byte array?

Re: Save multiple files in the cloud

Posted: Sat Apr 29, 2023 3:39 pm
by EVG
Right now I'm using two different save files. The first file saves the general settings and game currency, the second saves the gameplay, and when a new game starts, the second file is deleted. Would it be correct in this case (for normal saving in Google Play Save Cloud) to make all saves into one file? How, in this case, to completely remove all keys of the gameplay, but leaving the main settings and game currency saved? Can save keys be grouped somehow? Or how to do it correctly using Easy Save?

Re: Save multiple files in the cloud

Posted: Sat Apr 29, 2023 3:51 pm
by EVG

Code: Select all

//Save
	byte[] savedGameProgressData = ES3.LoadRawBytes(SaveManager.SaveDataFileName);
	ES3.Save("GameProgressData", savedGameProgressData);
	byte[] savedData = ES3.LoadRawBytes();
	SaveGame(game, savedData, new TimeSpan());

//Load
	ES3.DeleteFile();
	ES3.DeleteFile(SaveManager.SaveDataFileName);
	ES3.SaveRaw(loadedData);
	ES3.SaveRaw(ES3.Load<byte[]>("GameProgressData"), SaveManager.SaveDataFileName);
	ES3.DeleteKey("GameProgressData");
Or, for example, would such a decision be correct?

Re: Save multiple files in the cloud

Posted: Sun Apr 30, 2023 9:29 am
by Joel
EVG wrote: Sat Apr 29, 2023 3:51 pm

Code: Select all

//Save
	byte[] savedGameProgressData = ES3.LoadRawBytes(SaveManager.SaveDataFileName);
	ES3.Save("GameProgressData", savedGameProgressData);
	byte[] savedData = ES3.LoadRawBytes();
	SaveGame(game, savedData, new TimeSpan());

//Load
	ES3.DeleteFile();
	ES3.DeleteFile(SaveManager.SaveDataFileName);
	ES3.SaveRaw(loadedData);
	ES3.SaveRaw(ES3.Load<byte[]>("GameProgressData"), SaveManager.SaveDataFileName);
	ES3.DeleteKey("GameProgressData");
Or, for example, would such a decision be correct?
This would indeed be a way to approach this if you wanted to merge the two files into a single file. However, personally for simplicity if I have two seperate files, I would upload them to the cloud as two seperate files to make debugging easier. This is down to personal preference though.