skinwalker
Member
Hi,
This is my hotbar setup (not as usual hotbar just because I needed some different fucntionality)
and this is the hotbar ui (without the saver)
Now the way I save is like this
Get the savers methods
And when I load
Here some utility script
Eg:
FirstSlot - empty
SecondSlot - empty
Third slot - Syringe
SaveLoad
Syringe appears on First slot.
I use the same setup for Weaponry inventory and same problem appears.
I hope you will be able to find how to fix this bug and give me some info.
This is my hotbar setup (not as usual hotbar just because I needed some different fucntionality)
and this is the hotbar ui (without the saver)
Now the way I save is like this
OnSave..
SaveSystemManager.Save(0, false);
var bridgeSaver = InventorySaverUtilityBio.GetSaverSerializedData(InventorySaverKeys.PlayerBridgeSaver);
ES3.Save(InventoriesSaveFile.PlayerInventoryBridgeKey, bridgeSaver, filePath);
// I save some grid UIs here as well, which work fine
Get the savers methods
public static string GetSaverSerializedData(string saverKey)
{
var saverBase = FindSaver(saverKey);
var isDataRetrieved = SaveSystemManager.TryGetSaveData(saverBase.FullKey, out Serialization serializedData);
var data = SaveSystem.Serialize(serializedData);
return data;
}
private static SaverBase FindSaver(string saverKey)
{
var saverBase = Object.FindObjectsOfType<SaverBase>().FirstOrDefault(s => s.FullKey.Contains(saverKey));
if (saverBase == null)
{
Debug.LogError($"Saver with key {saverKey} doesn't exist");
return null;
}
return saverBase;
}
And when I load
private void LoadBridge()
{
var bridge = ES3.Load<string>(InventoriesSaveFile.PlayerInventoryBridgeKey, filePath);
LoadPlayerBridgeSaver(bridge);
}
public void LoadPlayerBridgeSaver(string s)
{
InventoryUtils.LoadSaver(s, InventorySaverKeys.PlayerBridgeSaver);
}
Here some utility script
Now the inventory collections are empty, but if I add the ItemViewSlotsContainerSaver to the UI, and save / load it the same way as above - the items will show. Their slots wont be correct though, if I got an empty slot in the middle the item will go there, its trying to fill in the gaps.public static void LoadSaver(string data, string saverKey)
{
var saveData = SaveSystem.Deserialize<Serialization>(data);
var saverBase = FindSaver(saverKey);
saverBase.DeserializeAndLoadSaveData(saveData);
RedrawGrids();
}
private static void RedrawGrids()
{
var grids = Object.FindObjectsOfType<ItemShapeGrid>();
foreach (var grid in grids)
{
grid.Draw();
}
}
Eg:
FirstSlot - empty
SecondSlot - empty
Third slot - Syringe
SaveLoad
Syringe appears on First slot.
I use the same setup for Weaponry inventory and same problem appears.
I hope you will be able to find how to fix this bug and give me some info.