On Tab Change ValueAttributeView Uses Previous Tab's Slot Position

pako

Member
Hi Santiago,

I have setup 4 tabs in the Inventory Grid, and each Tab contains 10 slots.

In a Description Panel/Item Description I have set a Category Attribute View Set, which is setup with 4 elements, e.g. Armor, Weapon, etc. Each element corresponds to the Items in each Tab, and it's setup with an Attribute View to display a specific Attribute, e.g. Armor, Damage, Health, etc.

Mostly it works well. So, in Play Mode when I hover the mouse pointer over the Item Slots in each Tab, the correct value for the Attribute is displayed in the Description.

However, I have noticed a small glitch: Let's say that the mouse pointer is in Tab 1, slot 5. If I switch to another tab, the Attribute value in the Description corresponds to the slot selected (hovered over) in the previous tab, i.e. slot 5 in this example. If I keep switching tabs (without hovering over a slot), the value in the description always corresponds to slot 5, but it's correct for the Item at slot 5 in the New Tab. Of course, if I hover over slot 10 in any tab and start switching tabs (without hovering over a slot), the Attribute value in the Description corresponds to slot 10.

The values displayed are always correct. However, I would expect the desired behavior to be that upon switching Tab, either there would be no value displayed until I hover the pointer over a slot in the new tab, or the value displayed would correspond to the 1st slot in the new Tab.

I have played around with several settings but I can't fix it. Is there a way to achieve the desired behavior?

Thanks in advance
 
I checked the demo scene and it works as expected in there.

Doing a quick test I found that what you are looking for is this setting
1739178185540.png

You'll find this component on the same gameobject as your InventoryGrid normally.
You can search for that component in your scene by pasting the component name in the hieracrhy window search:
ItemViewSlotContainerDescriptionBinding

I hope that helps :)
 
I checked the demo scene and it works as expected in there.

Doing a quick test I found that what you are looking for is this setting
View attachment 13672

You'll find this component on the same gameobject as your InventoryGrid normally.
You can search for that component in your scene by pasting the component name in the hieracrhy window search:
ItemViewSlotContainerDescriptionBinding

I hope that helps :)

Thank you for your reply,

Unfortunately it didn't help, as I already had the same settings.

1739186561252.png

Could some other settings be relevant?
 
That's odd. That should ensure the description is redrawn each time the InventoryGrid is drawn.
Does it work for you in the demo scene?

Also is there any way you can reproduce your issue in another scene and send it to me? Or tell me the reproduction steps.
 
Also just to be sure, double check that your Description is correctly bound to the correct IvnentoryGrid just in case
 
That's odd. That should ensure the description is redrawn each time the InventoryGrid is drawn.
Does it work for you in the demo scene?

Also is there any way you can reproduce your issue in another scene and send it to me? Or tell me the reproduction steps.
I'll try and do that.

I'm in the process of stepping through the code.

I noticed that in the ItemViewSlotContainerDescriptionBinding class, the DrawDescriptionOfSelectedSlot() method gets the selected slot from:

var selectedSlot = m_ItemViewSlotsContainer?.GetSelectedSlot();

Initially, when the 1st tab is drawn selectedSlot is null, and the 1st slot is automatically selected.

Then if I hover the pointer over some slots, and then switch tab, the selectedSlot gets the value of the slot corresponding to the position of the last slot visited in the previous tab.

I guess that's re-describing the problem.

I'll try to figure out where/how it finds that value, instead of resetting (apparently to null) and if I don't find a solution, I''l try to reproduce in another scene to send you.
 
That's odd. That should ensure the description is redrawn each time the InventoryGrid is drawn.
Does it work for you in the demo scene?

Also is there any way you can reproduce your issue in another scene and send it to me? Or tell me the reproduction steps.
It's exactly the same behavior in the Demo Scene.

The last item hovered over or clicked on any tab, will persist on other tabs too, as the automatically pre-selected slot.

It doesn't matter if the slot is occupied or not, either in the initial tab or the other tabs. If the slot is empty, it still gets selected when the tab is switched to (description: "Nothing Selected"). If you hover over an empty slot in a tab, say position 3, and switch to another tab, which has an item in position 3, it will be selected, and its description will be displayed.

So, you can check this behavior in the Demo scene.

EDIT: Just to be clear: The description is redrawn, but it's redrawn with the wrong slot selected. I believe that the expected behavior for the pre-selected slot after switching Tabs, should be the 1st slot in the Tab.
 
Last edited:
Ah, I must have misunderstood your issue. Because the demo scene works as expected
Unity_LA8SywVf98-ezgif.com-optimize.gif
When switching tabs it selects the selected slot.

Now if you want to select slot 1 whenever you switch tab, that's something else. I'm afraid we don't have an option for that by default.
So I added it for you :)
Just replace this script InventoryGridTabControlBinding. You'll find a new option m_SelectSlot0OnChangeTab

If you tick that new option it should select slot 0 :)
 

Attachments

Back
Top