Unclaimed Package Is this your package? Claim it to unlock full analytics and manage your listing.
Claim This Package

Install via UPM

Add to Unity Package Manager using this URL

https://www.pkglnk.dev/juanpablomaggi-savesystem.git

README Markdown

Copy this to your project's README.md

Style
Preview
pkglnk installs badge
## Installation

Add **Shank Game Tools - Save System** to your Unity project via Package Manager:

1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/juanpablomaggi-savesystem.git
```

[![pkglnk](https://www.pkglnk.dev/badge/juanpablomaggi-savesystem.svg?style=pkglnk)](https://www.pkglnk.dev/pkg/juanpablomaggi-savesystem)

README

GameTools-UnitySaveSystem

A lightweight and flexible save system for Unity, designed to be easy to integrate and adaptable to different project needs.

Features

  • Simple and modular architecture.
  • Methods to save, load, and delete game data.
  • Fully integrated with the Unity Test Framework.
  • Flexible design for different save/load strategies.

Getting Started

Installation

On Unity's Package Manager, click on the + button and add a new package from git URL. Then add the URL https://github.com/juanpablomaggi/GameTools-UnitySaveSystem.git#1.0.2

Let the package import automatically.

Usage

  1. Define a DTO class for the data you want to save

[!IMPORTANT] Remember to make the class serializable.

    [System.Serializable]
    public class SavedPlayerData
    {
        public int Health { get; set; } = 100;
        public string Name { get; set; } = "SavedPlayer";
    }
  1. Implement ISaveable in your object, using the DTO class as type:
    public class Player : ISaveable<SavedPlayerData>
    {
        public string SaveKey => "SavedPlayer";
        public string Name { get; set; }
        public int Health { get; set; }

        public SavedPlayerData CaptureState()
        {
            return new SavedPlayerData { Name = Name, Health = Health };
        }

        public void RestoreState(SavedPlayerData state)
        {
            Name = state.Name;
            Health = state.Health;
        }
    }
  1. Initialize the SaveService and register your saveable objects. When you save the game, it will capture the current state of the object to save.
    public class GameManager : MonoBehaviour
    {
        [SerializeField] private Player player;
        private ISaveService saveService;

        private void Awake()
        {
            saveService = new SaveService();
            saveService.Init();
        }

        private void Start()
        {
            saveService.Register(player);

            player.Name = "Player1";
            saveService.SaveGame();
        }
    }
  1. Load the game by calling LoadGame on the service:
    public void LoadGame()
    {
        saveService.LoadGame();
    }

[!TIP] If an ISaveable object is registered after loading, the system will immediately inject the previously saved data.


Changelog

Changelog for this project. Latest release 1.0.2

Future Plans

  • Create a IStorage interface to abstract the storage mechanism (Currently only Binary serialization).
  • Create a tool for save preferences management.

Comments

No comments yet. Be the first!