Game data serialization system for Unity game engine.
First make sure to use GameSerialization namespace:
using GameSerialization;
- using SaveableProperty attribute for your properties:
[SaveableProperty] public Vector3 vectorToSave {get; set;}
- using SaveableField attribute for your fields:
[SaveableField] public Vector3 vectorToSave;
- implementing IOnSaveGameMethod and IOnLoadGameMethod interfaces for your class:
public class ExampleSaveDataClass : MonoBehaviour, IOnSaveGameMethod, IOnLoadGameMethod { private float dataToSave; public void OnSaveGameMethod(SerializationInfo info) { SerializationHelper.SaveObject(info, this, dataToSave, typeof(float)); } public void OnLoadGameMethod(SerializationInfo info) { SerializationHelper.LoadObject(info, this); } }
public SavingManager savingManager; ... savingManager.SaveGame(saveName);
public SavingManager savingManager; ... savingManager.LoadGame(saveName);