Item Slot Restriction Issue

Hey there!

I have a quick question about how to handle some logic. When trying to drag an item that is currently Equipped on an Item Slot Collection onto my main inventory (also an Item Slot Collection), the item that is currently equipped disappears. This is likely due to the fact that the item that is in the main item slot collection cannot be assigned to the Equipment Slot. However the system doesn't seem to detect this. Here is a video of the issue: https://streamable.com/k44ny5 (the issues show up at around 18 seconds in, you can see the head and chest gear disappear when dropping on the wood)

Under the hood I am using Item View Slot Category Restrictions for the Equipment Slots so that it only accepts Head Wear, Chest Wear etc. It kind of looks like the system needs to search if the object that is being dropped on matches the Item View Category Restriction set for the item that is being dragged?

Thanks!!
 
I'll have a look at this in more detail on Monday.
I'm guessing it has something to do the SmartExchange action for drag & drop. It might not be smart enough... exchanging between two ItemSlotCollection is not something I've tested enough.

But right now what you can do is have a look at the Drag&Drop Condition and Actions. You can write your own custom ones specifying the source and destination ItemCollection or ItemViewContainer Panel. That would allow you more control over how it works.


Also if you want to change the preview of the drag&drop this can be done with a custom ItemViewModule which inherits the IItemViewSlotDropHoverSelectable interface. You can learn more here:
 
Thanks so much! I managed to get it working with a custom version of the smart exchange scripts. I added some lines to the CanDrop fuction:

C#:
            var sourceSlotCanContain = destinationIsNull ? true : itemViewDropHandler.SourceItemViewSlot.CanContain(itemViewDropHandler.DestinationItemInfo);

            var destinationSlotCanContain = sourceIsNull ? true : itemViewDropHandler.StreamData.DestinationItemViewSlot.CanContain(itemViewDropHandler.SourceItemInfo);

            if (m_Debug)
            {
                Debug.Log($"sourceCanGive {sourceCanGive}\n" +
                          $"destinationCanGive {destinationCanGive}\n" +
                          $"sourceCanAdd {sourceCanAdd}\n" +
                          $"destinationCanAdd {destinationCanAdd}\n" +
                          $"sourceIsNull {sourceIsNull}\n" +
                          $"destinationIsNull {destinationIsNull}\n" +
                          $"sourceSlotCanContain {sourceSlotCanContain}\n" +
                          $"destinationSlotCanContain {destinationSlotCanContain}\n");
            }

            if (sourceIsNull && destinationIsNull) { return false; }

            return (sourceSlotCanContain && destinationSlotCanContain && sourceCanGive && destinationCanAdd);

I'm not sure if I would need to add anything to the SmartExchangeAction script. I did add this as a safety net:

C#:
            var sourceSlotCanContain = destinationIsNull ? true : itemViewDropHandler.SourceItemViewSlot.CanContain(itemViewDropHandler.DestinationItemInfo);
            var destinationSlotCanContain = sourceIsNull ? true : itemViewDropHandler.StreamData.DestinationItemViewSlot.CanContain(itemViewDropHandler.SourceItemInfo);

            if (!sourceSlotCanContain || !destinationSlotCanContain) return;
 
Thank you very much for sharing your solution! I think this is exactly what I would have done.

I will add them to UIS in the next update

If you find any issues with your solution please let me know and I'll make sure to look into it in more detail
 
Top