# Save/Load System

## Overview

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

{% embed url="<https://www.newtonsoft.com/json>" %}

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:

<figure><img src="/files/KKboneHVhpB8nLiTXKq4" alt=""><figcaption><p>Saving</p></figcaption></figure>

<figure><img src="/files/XiNT0hE1AkA5ouGt00rT" alt=""><figcaption><p>Loading</p></figcaption></figure>

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.

<figure><img src="/files/4VkO5VNX98W32OQtj1QQ" alt=""><figcaption></figcaption></figure>

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:\ <br>

<figure><img src="/files/kSq5lP28osWkNhBL01Er" alt=""><figcaption></figcaption></figure>

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:<br>

<figure><img src="/files/HK6TwPQC2wEdcu9Gp3QP" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://malbersanimations.gitbook.io/animal-controller/save-load-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
