Hi
I’m trying to drag items inside UI panel (inventory system). Methods for drag event:
public void OnBeginDrag(PointerEventData eventData)
{
itemBeingDragged = gameObject;
startDraggingPosition = transform.position;
}
public void OnDrag(PointerEventData eventData)
{
transform.position = eventData.position;
Debug.Log("Start position: " + startDraggingPosition + " currentPosition: " + transform.position + " mousePosition: " + Input.mousePosition);
}
When I start to drag item, I get ‘normal’ debug log:
However item disappears, and transform shows why:
Conclusion: somehow item’s position is updated to very strange one
Questions:
- What did I miss? (tried even ScreenToWorldPoint but it didn’t work - here’s GUI element so I suppose it shouldn’t work)
- Is there a better/more practical way to do items dragging in UI inventory?