I've got some custom savers. For example this one.
Spoiler
Code: Select all
public class InventorySaver : Saver
{
[Serializable]
public class Data //Contains data for serializing
{
public InvItem[] items = new InvItem[6];
public InvItem[] itemsMare = new InvItem[6];
}
//Arrays to operate with
private InvItem[] itemsArray;
private InvItem[] itemsMareArray;
public override void Start()
{
itemsArray = GameManager.Instance.inventory.items;
itemsMareArray = GameManager.Instance.inventory.itemsMare;
}
public override string RecordData()
{
Data data = new Data();
Array.Copy(itemsArray, data.items, itemsArray.Length);
Array.Copy(itemsMareArray, data.itemsMare, itemsMareArray.Length);
return SaveSystem.Serialize(data);
}
public override void ApplyData(string s)
{
Data data = (Data)SaveSystem.Deserialize<Data>(s);
if (data == null) return;
Array.Copy(data.items, itemsArray, itemsArray.Length);
Array.Copy(data.itemsMare, itemsMareArray, itemsMareArray.Length);
}
}
I should mention that when I exit to the main menu, all objects are destroyed, so all the savers in the main menu are "clean". Apparently the data itself remains for some reason.
Any idea? Thanks!