Save System

A basic save system based on unity's JsonUtility

The save system is built on Unity's Json Utility which saves an object in a .json file. All the saves are located at Application.persistentDataPath which is located at C:\Users\<user>\AppData\LocalLow\<company name>on widows.

Methods

Name
Description

Save

Saves the target object as .json file.

Load

Loads the target generic type from .json file with the given name

Load All

Loads all the target generic types from all .json files in the save path

Delete

Deletes .json file with the given name

Delete All

Deletes all .json files in the save path

Example

To start using the save system, first add the namespace FPSFramework to the class you want to save and load from, like this:

using Akila.FPSFramework;

Now create a new class like this:

[System.Serializable]
public class Data
{
    public string name;
}

In Start(), call SaveSystem.Load(), and in OnApplicationQuit(), call SaveSystem.Save() inside the class you want to save and load from, like this:

public Data data = new Data();

private void Start()
{
    SaveSystem.Load<Data>("fileName");
}

private void OnApplicationQuit()
{
    SaveSystem.Save(data, "fileName");
}

Last updated