Pepersistent
Pepersistence is an extensible save/load system that simplifies game data persistence in Unity. It provides a flexible architecture through ISaveData and ISavable interfaces, supporting custom serialization handlers and seamless integration with dependency injection frameworks. Built on Json.NET, it reduces boilerplate code for managing game state across your project.
com.aleshmandr.pepersistent Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/pepersistent.git 
README Markdown
Copy this to your project's README.md
## Installation
Add **Pepersistent** 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/pepersistent.git
```
[](https://www.pkglnk.dev/pkg/pepersistent)Dependencies (1)
README
Pepersistence
Extensible save/load system package for Unity game engine, designed to simplify the management of game data persistence.
Installation
You can install Pepersistence in one of the following ways:
Using Unity Package Manager:
- Open your Unity project.
- Go to the Unity Package Manager via
Window > Package Manager. - Click on the "Add package from git URL" button.
- Enter the following URL:
https://github.com/Aleshmandr/Pepersistence.git.
Manual Download:
Alternatively, you can download the source files directly from the Pepersistence GitHub repository and import them into your Unity project manually.
Package dependencies:
This package depends on Json.NET by Newtonsoft (com.unity.nuget.newtonsoft-json version 3.1.2)
How to use
Follow these steps to integrate Pepersistence into your project:
Create a class for your global savable game data that implements the
ISaveDatainterface:[Serializable] public class GameSaveData : ISaveData { public LevelsSaveData Levels; }[Serializable] public struct LevelsSaveData { public int CompletedCount; }Create your own persistence manager class by extending the
BasePersistenceManager<T> where T : ISaveData, new()class:public class PersistenceManager : BasePersistenceManager<GameSaveData> { public PersistenceManager(ISaveSource saveSource) : base(saveSource) { } }Ensure that all objects you want to save implement
ISavable<T> where T : ISaveData:public class LevelsDataManager : ISavable<GameSaveData> { private int completedCount; public void Load(GameSaveData saveData) { completedCount = saveData.Levels.CompletedCount; } public void Save(ref GameSaveData saveData) { saveData.Levels.CompletedCount = completedCount; } }Register all objects you want to save with your
PersistenceManager:... persistenceManager.Register(levelsDataManager); ...Alternatively, if you use dependency injection (DI) in your project, you can register the necessary objects inside your PersistenceManager:
public class PersistenceManager : BasePersistenceManager<SaveData> { public PersistenceManager(ISaveSource saveSource, IReadOnlyList<ISavable> savableObjects) : base(saveSource) { foreach (var savableObject in savableObjects) { Register(savableObject); } } }Where
LevelsDataManagerimplementsISavableinstead ofISavable<GameSaveData>:public interface ISavable : ISavable<SaveData> { }Load/save your game data
... persistenceManager.Load(); ... persistenceManager.Save();You can delete all save files in the editor by selecting the
Edit > Pepersistence > Clear All Saves. This action will remove all files with an extension that matches the pattern^.*sav$, including the default.jsav. Therefore, if you create your own save file format, make sure to use a file extension that matches this pattern, as it will also be removed when clearing saves.
Features
- Contains classes for local saves, supporting both binary and JSON formats.
- Extensibility: You can implement your custom save source, such as cloud-based saves, to meet your specific needs.
- Save file encryprion
- Save data migrations
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In