Reputation: 278
I am creating an inventory system in Unity, and I have been baffled by a troublesome enigma. The OnMouseEnter function fails to execute when I drag the item in my inventory system back to previous slots. I have used the Control Double keyboard short cut to create three slots. They are named "Slot", "Slot(1)", and "Slot2". When I drag my item to Slot(1), I can't drag it back to the first slot, "Slot". When I drag my item to Slot(2), I can't drag it to my second slot, "Slot(1)". I have noticed that the OnPointerEnter() method does not get called when I try to drag the item from "Slot(2)" to "Slot(1)" or "Slot". Why is that?
This inventory moving script is supposed to work by setting the parent of the item to the slot that the mouse is dragging to and then positioning it to Vector3.Zero in local position. The InventoryController script is attached to the UIImage, inventory, the SlotController script is attached to the UIImage, Slot, and the Item script is attached to the UIImage, Item. My Hierarchy, Inspector, and Scripts are below in images. Thank you for helping me in advanced!
Upvotes: 1
Views: 1211
Reputation: 2167
Well I can see you are getting a null reference exception in OnEndDrag. do a check if the controller object has a reference.
Upvotes: 0