So I have created an inventory system, now implemented drag and drop to move items around from 1 slot to another. I have set up: Canvas, Inventory(panel), Slot(image), inventoryimage(image). When I drag an item from 1 slot to another it works fine, but when I drag it outside of a slot, the item that I am dragging will just drop there instead snapping back into its original slot.
on the begin drag interface I check what the current parent is by declaring a Transform in the beginning of the class and in the OnBeginDrag I initialise it by saying : startParent = transform.parent;, then in OnEndDrag I check if the transform.parent is the same but including an if statement if(transform.parent == startParent), for some reason, it doesn’t matter where I drop the item I am dragging it always says the startParent is the same as the transform.parent. When I Debug.Log(transform.parent); and put that on a IPointerEnter then it will also tell me that the parent is always the same nomatter if I have the cursor going into the Canvar, inventory(panel) or the Slot(image).
I have seen more people with a similar problem but no solutions. Because I was going insane and checked everything, even downloaded different unity versions to check if that was it, I ended up watching a tutorial on drag and drop and followed it step by step, doing everything the exact same way as the person in the video and also ended up with an error. This is the video I was following: Unity UI Drag and Drop Tutorial - YouTube, I get the error: Unityengine.EventSystems does not contain a definition for itemBeingDragged. < Also when I type “IDragHandler.” it only comes up with 2 possible things which are “Equals” and “ReferenceEquals”.
I don’t know if this has to do with the problem I am having with my own drag and drop system but it definitely isn’t right, also I have had someone else I know that does c# follow the exact same video to see if he could get it to work and he gets the exact same error I am getting. I am literally going insane because I just don’t know if it’s me thats doing something wrong, or its unity being buggy or something.