I am having an issue with my drag and drop. I am making a mostly UI driven game, although there will be some 3d animations below the main UI and so I wanted to use Worldspace or Camera so that way I can show things outside of just my UI.
If I have my canvas in Screen Space Overlay things drag just fine. The moment I try to use WorldSpace or Screen Space Camera things start to get wacky. The coordinates just go all over the place. I have tried using Camera.main.ScreenToWorldPoint to transform the position but that just seems to give me bad data as well. Is there something Iām missing here?
public void OnBeginDrag(PointerEventData eventData)
{
StartDragPosition = eventData.position;
difference = StartDragPosition - this.transform.position;
}
public void OnDrag(PointerEventData eventData)
{
//This offset helps us keep our mouse position on the object itself
transform.position = eventData.position - new Vector2(difference.x, difference.y);
}