I’ve built a basic drag and drop, from icons in the UI into the scene.
I’m currently having an issue with detecting if while onEndDrag the user is still over the UI as I want to block item creation.
I’m using the standard method to test if the user is still over the UI, but it is always returning true. I imagine this as the start of the drag and drop is from the UI.
-
Is there anyway to get around this?
-
Is this a potential bug?
bool IsPointerOverGameObject(int fingerId)
{
EventSystem eventSystem = EventSystem.current;
return (eventSystem.IsPointerOverGameObject(fingerId)
&& eventSystem.currentSelectedGameObject != null);}
Above is my C# implementation to check if the pointer is over the UI. This is called in the onEndDrag function.
public virtual void OnEndDrag(PointerEventData eventData)
{
..
if (!IsPointerOverGameObject(eventData.pointerId))
..
}
Any help would be highly recommended.