Skip to content

JSON file saving and loading system with unity to save and load generic types. Supports multiple save slots and profiles

License

Notifications You must be signed in to change notification settings

ErencanPelin/Unity-Saving-Loading-with-JSON

Repository files navigation

Unity-Saving-Loading-with-JSON

JSON file saving and loading system with unity to save and load generic types. Supports multiple save slots and profiles.

Dependencies

  • newtonsoft.json (any version)

Usage

  1. Create a custom save profile data object to save custom data:
using SaveLoad;

[System.Serializable]
public record MySaveData : SaveProfileData
{
    public Vector3 position;
    public int currentLevel;
    public float health;
    public float xp;
}
  1. Save values to the save profile data object:
var saveData = new MySaveData
{
    position = transform.position,
}
//OR
var saveData = new MySaveData();
saveData.position = transform.position;
  1. Save the data:
saveData.SaveAs(
/*save name*/ "mySave", 
/*overrite existing save with same name?*/ false);

The repo also contains a sample save profile inside Saves

using SaveLoad;

Saves.playerSaveData.position = transform.position;
Saves.playerSaveData.SaveAs("playerData", "false");

About

JSON file saving and loading system with unity to save and load generic types. Supports multiple save slots and profiles

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages