Save System is a simple save system for Unity. It allows you to save and load scene objects and their components.
- Saving and Loading
- Using the Savable Component
- Prefab Registry
- Create your own Savable Component
- Data Types
- Supported Types
- Install via git URL
- License
You can save and load the current scene by using the SaveLoadManager
class.
using Kekser.SaveSystem;
// ...
SaveLoadManager.Save(path);
SaveLoadManager.Load(path);
You can save and load a scene object by adding the Savable
component to it.
You can use it on any scene object, but it is recommended to use it on Prefabs.
This package contains a SavableTransform
and a SavableRigidbody
component.
You can use them to save and load the transform and the rigidbody of a scene object.
To be able to save and load prefabs, you have to register them in the PrefabRegistry
.
You can create and update the prefab registry by clicking on Tools/Save System/Update Prefabs
.
This is a manual process, and needs to be done every time you add a new prefab to your project.
You can create your own savable component by using the Savable
, Save
or Load
attribute.\
using Kekser.SaveSystem;
[Savable]
private int _score = 100;
using Kekser.SaveSystem;
private int _score = 100;
[Save]
private void Save(DataObject data)
{
data.Add("Score", new DataElement(_score));
}
[Load]
private void Load(DataObject data)
{
_score = data.Get<DataElement>("Score").ToObject<int>();
}
These attributes are also usable on static fields and methods.
The DataObject
class is a dictionary that contains other DataObject
, DataArray
and DataElement
objects.
The DataArray
class is a list that contains other DataObject
, DataArray
and DataElement
objects.
The DataElement
class is a wrapper for any supported types.
byte[]
int
float
bool
string
Vector2
Vector3
Vector4
Quaternion
Color
Type
Guid
IList
IDictionary
Array
Enum
Class
Struct
GameObject
You can add this package to your project by adding this git URL to the package manager:
https://github.com/DerKekser/unity-save-system.git?path=Assets/Kekser/SaveSystem
This library is under the MIT License.