Inventory items dissapear from UI on scene change

ilofosho

New member
Hello!

I am using your inventory system asset and I have a problem regarding disappearing items from the Inventory UI. I am working on RPG where each scene is a separate map chunk and player prefab with Inventory component is always present in the scene. My UI with Inventory System Manager is set to Don't destroy on load and is persistent between the scenes (so there is always only one same instance in the game).

What I am experiencing is this:
1) I load arbitrary scene from editor and open Inventory UI - everything is shown perfectly, I can see items in UI and they are shown also in player's Inventory component
2) I go to another part of the map, which means new scene load - now I see empty inventory UI (each ItemViewSlotForGrid in the GridView is populated with Empty Item View gameObject), but I can see the items in player's Inventory component - that means items are present, but they are not showing in the UI
3) However, when I continue playing, pickup some object(s), open inventory UI and hover mouse cursor over the UI, it looks like UI is redrawn and all items are being shown correctly again

Can I ask someone for the advice where should I look reagarding the debugging of this problem? Why the items probably disappear and what should I do to prevent this behaviour? Thanks a lot in advance for your answers!
 
That's an odd one, I haven't heard that before.

Are you using the SaveSystemManager? I'm wondering if you might have ticked the option to load on scene transition. Perhaps that's causing issues when loading scenes additively.

It does seem the issue is only on the UI part. since you say the Inventory component has all the items.
The first thing I would check is if the IDs of the unique items are the same when you switch scenes. If they are then it should be fine, and we can be confident the issue is UI specific.

The other thing I would check is when exactly the UI draws empty itemViews. You could do that by adding a break point or a Debug.Log in the Draw function of the InventoryGrid.

Finally if you can't figure it out, you can work around the issue by forcing the UI to redraw when opening the InventoryPanel. There is an option you can tick on the DisplayPanel ItemViewSlotContainer binding for that.

I hope that helps
 
Thank you very much @Sangemdoko for your insights!

I was able to solve this issue by setting Reset Draw On Open to true on ItemViewSlotsContainerPanelBinding

However, when checking IDs of the items in player's inventory, I noticed that the IDs are different on each scene. It happens on the item categories which are set as "Mutable". Can this behaviour signalize wrong Inventory setup or is it expected behaviour?
 
Unique&Mutable itemDefinitions can have multiple items with different IDs. But once an ID is set on an Item Instance it should not change normally.
Common&Mutable Items do not change IDs, but they can stack with other similar items. In that case one of the Items will assimilate the other so you'll have a single ID but a bigger Amount.

When loading items from the save data, if an Item is already registered with the saved ID and is not the same as the one being loaded, then the saved item will be given a new ID.

I hope that makes sense
 
Top