Drag not working for equipment UI

Exi-G

New member
I've duplicated the RPG inventory UI and spawned it into my scene. I have done all the necessary changes to make sure the inventory works with my player.

I can do drag and drop in the inventory UI, but when I try to drag and drop in the equipment UI, it doesn't work. The drag don't even get started. I put a debug in the HandleItemViewSlotBeginDrag method of ItemViewSlotDragHandler class and when I drag in the equipment UI, the log don't print but when I drag in the inventory UI the log is printed.

Link to discussion on discord: https://discord.com/channels/476506682382483456/760110372035493928/850088526849900614

I tried to add an equipment in the UIS demo scene then drag on the existing equipment in the demo scene also stop working.

Screenshot of the equipment panel:

Equipment Panel.PNG

Screenshot of equipment Itemview Slot Container:
Equipment Itemview Slot Container.PNG

Video:
 
That's a weird issue.

First thing I would like you to check is if at runtime, after you open the Equipment UI are these two fields circled in blue assigned?
1623052512246.png

If that's the case then it would confirm that your UI is initialized correctly.

If that's the case then the second thing I would like you to check is the Item View Slots for your Equipment. Especially the Canvas Group and the Item View Slot options, make sure they are set to be interactable.
1623052732381.png


If both of those are working correctly, I would suggest you add more Debug.Logs to see at which points it fails.
Start with the "Action Button" script (the base class of the Item View Slot). There is an "OnBeginDrag" function which sends the original event.

If the debug there works, it means the issue is either with the Item View Slot Container or the Drag Handler. Otherwise the issue is that something is blocking the interaction with the selectable object.
 
I have tested and all fields in inspector are assigned as expected. I added debug in the "OnBeginDrag" function as suggested and the log are being printed onto the console.

I have Item Action Panel for the equipment UI but when i click on the equipped item slot the action panel doesn't show but it shows for inventory.
 
Ok so the Item View Slots do receive the interaction events, but it would appear the Item View Slot Container does not...
Just to be sure please add a Debug.Log at each step to know exactly where the issue is.

So the first one was the ActionButton which you already added

Then in the ItemViewSlotContainerBase class, in the Initialize function there is a segment that looks like this:
Code:
itemViewSlot.OnBeginDragE += (pointerEventData) =>
{
    if (m_ItemViewSlotDragEventData.PointerEventData != null) {
        //The drop event is being used, so it cannot be used again until the drag ends.
        return;
    }

    m_ItemViewSlotDragEventData.SetValues(this, localIndex);
    m_ItemViewSlotDragEventData.PointerEventData = pointerEventData;
    OnItemViewSlotBeginDragE?.Invoke(m_ItemViewSlotDragEventData);
};
Add two Debugs one at the start, another at the end of that lambda function.

Then in the ItemViewSlotDragHandler add two Debug.Logs in the HandleItemViewSlotBeginDrag function one at the start and one at the end.


If the issue is in the ItemViewSlotContainerBase like I presume, the debug.logs won't print at all.
If that's the case add more Debug.Logs in the Initialize function of the ItemViewSlotContainer to know if it is being initialized and to know the count of itemViewSlots and if any ItemViewSlot is null.

That should narrow down the issue quite a bit.

If I can't figure out what the issue is by the end of the week, I will suggest that you send your project to support@opsive.com such that I can investigate myself.
 
I have tried your suggestions and it seems the equipment ItemViewSlotsContainer is not being initialized. and the begin drag event is not triggered for ItemViewSlotsContainer and ItemViewSlotDragHandler

This even happen with the demo scene included with the inventory system. If i open the demo scene without touching the inventory UI object then everything is fine but if i touch the inventory UI and expand or select the game object then i get this behaviour where the equipment is not initialized
 
Last edited:
I tried but I can't seem to replicate your issue in the demo scene. Could you perhaps make a video with the reproduction steps? you can use streamble.com to share a video easily.

The ItemViewSlotsContainer should be initialized by the ItemViewSlotsContainerPanelBinding. Double check that you are indeed referencing it correctly.
1623741161139.png
Of course the Item View Slots Container Panel Binding must be a sibling component to the Display Panel or be set within the array of bindings.
 

Attachments

  • 1623741000540.png
    1623741000540.png
    162.7 KB · Views: 0
Hi, it seems someone potentially found an issue relevant to your issue:

I'm looking into this in more detail
 
Oh ok. Sorry I have been busy with work so i haven't got time to try out what you suggested yet. I will try it when i get some free time and let you know if i find anything
 
I have double check and i am referencing the equipment item view slot container in the item view slot container panel binding
Capture.PNG

And here is a video recording replicating the issue with the demo scene

When i fresh open the scene and play, the equipment drag and drop works fine but if is stop playing then the scene get dirtied or i make any changes in the scene and play again then the drag and drop stop working.
 
I'm stomped, I'm not sure what's happening.

It seems you are using a Editor extention that customizes your Hierarchy and your Inspectors. Is there any chance that this add-on has compatibility issues with custom insepctors written in UIElements? Could it cause compatibility issues with serialized and non-serialized values?

You said before that:
have tried your suggestions and it seems the equipment ItemViewSlotsContainer is not being initialized. and the begin drag event is not triggered for ItemViewSlotsContainer and ItemViewSlotDragHandler

In the ItemViewSlotsContainerBase script add a Debug.Log at the very top of the Initialize function. And add a few others throught the Initialize function to know when it returns. I fear that perhaps something is keeping the m_Initialized value to true even after entering play mode again where it should start as false.

If Initialize is never called, check the ItemViewSlotsContainerPanelBinding script and again, in the Initialize function double check that wasInitialized isn't true when you first start play mode.
 
It seems you are using a Editor extention that customizes your Hierarchy and your Inspectors. Is there any chance that this add-on has compatibility issues with custom insepctors written in UIElements? Could it cause compatibility issues with serialized and non-serialized values?
I am using odin inspector. I will try removing it and see if that is the cause of this issue.
 
I have imported the inventory system into a new project and tested everything works fine so i think it might have to be one of the plugins i am using causing that issue

I will try installing the plugins i am using in my project and see if i can find out which one is causing the issue.
 
Hi @Sangemdoko, I have solved the issue. It turns out it wasn't because of any of the plugins i had. The issue was caused by me enabling the Enter Play Mode Options in the unity editor and unchecking both Reload Domain and Reload Scene which is preventing the unity editor from reloading the the scene when i enter play mode and preventing the equipment container from re-initializing. After disabling this option in the editor, everything is working fine as expected.

Sorry for wasting your time on this and thanks for your help.
 
That's good, it wasn't a waist of time at all. Knowing that I might be able to do something about it. The "Enter Play Mode Options" are very useful to speed up iteration so i think it is worth supporting.
Thank you for getting to the bottom of this, If I can I will add a function to reset some values on domain reload.

Just out of curiosity, what Unity version are you using? Normally the Enter Play Mode Options should be resetting all none serialized values except static ones. So that might be a bug with the Unity version you are using.
 
Top