Encrypted local data storage in Unity runtime on any platform. Thread safe, Unity-Saver uses a dedicated non-main thread for Read/Write operations with files. Data can be stored in different locations:
- ✅ Persistent - Regular Unity PersistantDataStorage location
- ✔️ iOS
- ✔️ Android
- ✔️ Standalone
- ✅ Local - the current location of the executed app
- ❌ iOS
- ❌ Android
- ✔️ Standalone
- ✅ Custom - any path on your own
- ❌ iOS
- ❌ Android
- ✔️ Standalone
- Install ODIN Inspector
- Install OpenUPM-CLI
- Open a command line in Unity project folder
openupm add extensions.unity.saver
- Install ODIN Inspector
- Add this code to
/Packages/manifest.json
{
"dependencies": {
"extensions.unity.saver": "1.0.9",
},
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"extensions.unity.saver",
"com.cysharp",
"com.neuecc"
]
}
]
}
Usage is very simple, you have access to data through Data
property in the saver class.
Data
- current data with read & write permission (does not read and write from file)DefaultData
- access to default data, this data would be taken on Load operation, only if a file is missed or corruptedLoad()
- force to execute load from a file operation, returnsasync Task
Save()
- insta save currentData
to a file, returnsasync Task
SaveDelay()
- put save operation in a queue, if the same file is going to be saved twice, just a single call will be executed. Very useful when data changes very often and required to call Save often as well. You may call SaveDelay as many times as needed and do not worry about wasting CPU resources for continuously writing data into a file.
using Extensions.Saver;
public class TestMonoBehaviourSaver : SaverMonoBehaviour<TestData>
{
protected override string SaverPath => "TestDatabase";
protected override string SaverFileName => "testMonoBehaviour.data";
}
using UnityEngine;
using Extensions.Saver;
[CreateAssetMenu(menuName = "Example (Saver)/Test Scriptable Object Saver", fileName = "Test Scriptable Object Saver", order = 0)]
public class TestScriptableObjectSaver : SaverScriptableObject<TestData>
{
protected override string SaverPath => "TestDatabase";
protected override string SaverFileName => "testScriptableObject.data";
protected override void OnDataLoaded(TestData data)
{
}
}
using System;
using System.Threading.Tasks;
using Extensions.Saver;
public class TestClassSaver
{
public Saver<TestData> saver;
// Should be called from the main thread, in the Awake or Start method for example
public void Init()
{
saver = new Saver<TestData>("TestDatabase", "testClass.data", new TestData());
}
public TestData Load() => saver?.Load();
public async Task Save(Action onComplete = null) => await saver?.Save(onComplete);
}