[BUG] Saving an ItemSlotCollectionView through the BridgeSaver doesn't work (requires ItemViewSlotsContainerSaver)

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

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

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();
}
}
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.

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.
 
I'm very sorry about the delay.
Here is the updated InventoryBridgeSaver.
Please let me know if that fixes the issues for you.
If so I will add this change to the next update

If you find any other issues please let us know :)
 

Attachments

I'm very sorry about the delay.
Here is the updated InventoryBridgeSaver.
Please let me know if that fixes the issues for you.
If so I will add this change to the next update

If you find any other issues please let us know :)

I have been testing and will continue to do so, but so far things seem to be working correctly. I was able to get rid of the ItemViewSlotsContainerSaver for my 3 ItemSlotCollections and the bridge seems to be saving and loading them as it should. This even eliminated the other bugs I reported on Discord where if I had an item on slot1 and slot3, then save -> load it would show the items on slot1 and slo2 (fill the empty slot in between) while now they stay on slot1 and slot3 as they should.

I will report back any issues if they arise, thanks for the fix.
 
Back
Top