Forum rules - please read before posting.

Proper way to Load data

Hello. I'm implementing a custom Save System for Xbox. I wrote my iSaveFileHandler.

For the Save method I'm doing

var dataJson = JsonUtility.ToJson(dataToSave);
byte[] blobData = System.Text.Encoding.ASCII.GetBytes(dataJson);

and then send blobData to Xbox's Save method.

For Loading, I'm doing this,

var dataJsonString = System.Text.Encoding.ASCII.GetString(blobs[0].Data);
loadedData = JsonUtility.FromJson<string>(dataJsonString);

return loadedData;

I'm getting blobs from Xbox's Load method. I got these lines from a Sample provided in the Xbox GDK. However, the sample says that it assumed only 1 blob, hence blobs[0].

Will AC's loaded data be more than 1 blob? How could I retrieve the data from all blobs and send it to loadedData? I imagine I could do a for loop with blobs.Length. But how could I send it all to the same string?

Comments

  • Where/how the data is exactly stored would be down to Xbox - does the Save function allow you to specify an index? The blobs[index] may refer to which save slot you're dealing with.

  • I can specify where the data is saved by a name. I can use the saveId to specify which save slot it is as a suffix. But in the end it's the name. So I can I use the save file name. So with the Load function, I'm using that name to retrieve the data for that save file, which returns an array of blobs (for that one save file). So I wanted to convert the blobs to a string to return it in SaveFileHandler's Load method, which is the same I'm doing in the Save method, but backwards. But I'm unsure how I can do it if the retrieved array of blobs is more than one blob.

  • So while working on this I ran into another problem. As I said earlier, Xbox's save containers are created by name. And I thought I could use saveFile.name in the
    iSaveFileHandler Save method. I'm using the Action Save New Game in my main menu to start the game, but I guess that since the save file doesn't exist yet, saveFile.fileName is empty and thus, Xbox's Save fails. I also tried using saveFile.label but got the same result. I don't have save slots so I would have just one save file. What could I be doing wrong? How can I get the saveFile name as it's being created? I would need to use that same name to load the data. I'm happy to provide any more information. I'm using AC 1.74.2.

  • So with the Load function, I'm using that name to retrieve the data for that save file, which returns an array of blobs (for that one save file). So I wanted to convert the blobs to a string to return it in SaveFileHandler's Load method, which is the same I'm doing in the Save method, but backwards

    It's a question for Xbox - how the data gets stored within the blobs array isn't up to AC.

    I'm using the Action Save New Game in my main menu to start the game, but I guess that since the save file doesn't exist yet, saveFile.fileName is empty and thus, Xbox's Save fails.

    You don't need to rely on the fileName or label, just a unique identified that'll be consistent for that save. Use the ID number instead.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.