Save/Load System

Overview

The Save/Load system of the Inventory System is based off of JSON.Net.

Unity officially supports it, but does not support native Unity types like Gameobject or Vector3 etc, by default. You can use converters to get around it, but for now, that's not necessary.

Setting up the System

To set up the Save/Load system is super easy.

You can either make your own buttons/conditions for it, but in the InventoryCanvas, under the InventoryTabsArea, I've added a Save/Load button there for you.

To Save/Load, you simply either need to set the buttons up like this:

OR if you want to have another method to call Saving/Loading, just simply find a reference to InventoryMaster, and call:

  • To Save -> SerializeJSON()

  • To Load -> DeserializeJSON()

And that's it. It will then save at: Application.persistentDataPath under the file name of: playerInventories.json

Encryption

If you wish to enable AES256 encryption on your save data, you can simply do so by turning on Using Save System Encryption? on the Inventory Master component.

This will then encrypt your data to AES256 standard. You can find the Key and IV it uses to encrypt inside the JSONDataService.cs script:

If you want to generate a new KEY and IV, the easiest way I've found is to just use ChatGPT.

Simply ask it as I have below:

Last updated