LogoDocs

Usage

This section of the documentation explains how to use the asset

1. Implement ISaveable for Your Data

To make a script saveable, implement this interface:

public interface ISaveable
{
    SaveData Save();
    void Load(SaveData saveData);
}

Example:

public class PlayerData : MonoBehaviour, ISaveable
{
    [SerializeField] private string id = Guid.NewGuid().ToString();
    [SerializeField] private int health = 100;

    public string UniqueId
    {
         get
         {
             if (string.IsNullOrEmpty(id))
             {
                 id = Guid.NewGuid().ToString();
             }
   
             return id;
         }
    }
    
    public SaveData Save() 
    {
        return new SaveData 
        {
            data = JsonUtility.ToJson(health),
            uniqueID = UniqueId,
        };
    };

    public void Load(SaveData saveData) { 
        health = JsonUtility.FromJson<int>(saveData.data);
    }

2. Add SaveManager to Scene

Drag the SaveManager prefab into your scene or create your own by attaching SaveManager.cs to any GameObject. It will automatically find and save all active ISaveable objects.

Inspector options:

OptionDescription
Save FormatJSON or Binary
Encryption TypeNone, XOR, or AES
Enable Auto SaveEnables periodic background saves
Auto Save IntervalTime in seconds between auto saves
Auto Save SlotThe slot to use for auto saving
Auto Save Timer ModeJSON or Binary
Encryption TypeNone, XOR, or AES
OnDelete (Event)Called when a save is deleted
OnSave (Event)Called when a save is created
OnLoad (Event)Called when a save is loaded

3. Manual Save & Load

saveManager.Save("SaveSlot1");
saveManager.Load("SaveSlot1");

4. Auto Save

Enable Auto Save in the inspector or at runtime:

saveManager.EnableAutoSave = true;

5. Encryption Options

Encryption TypeDescription
NoneNo encryption
XORLightweight and fast
AESSecure encryption (key & IV auto-handled)

6. Save Formats

FormatDescription
BinaryFaster and more compact
JSONHuman-readable

File extensions:

.sav (Binary)

.json (JSON)

🧪 Demo Scene

Located in:

Assets > PixelArts > Basic Save System > Demo > Scene > Demo Scene.unity

Includes

The demo scene includes the following to showcase the functionalities of the asset

  • Runtime Save Panel
  • Dummy player data
  • Slot switching
  • Manual & autosave