With UGUI I would normally do something like this:
public static bool IsMouseOverUIObject ()
{
if (EventSystem.current != null)
{
PointerEventData eventDataCurrentPosition = new PointerEventData (EventSystem.current)
{
position = new Vector2 (Input.mousePosition.x, Input.mousePosition.y)
};
List<RaycastResult> results = new List<RaycastResult> ();
EventSystem.current.RaycastAll (eventDataCurrentPosition, results);
return results.Count > 0;
}
else
{
Debug.LogError ("No EventSystem present to check for 'InputValidation.IsMouseOverUIObject ()'.");
return false;
}
}
To check if the mouse was above some interactable object so that when I dragged a slider, I could stop my camera from spinning.
How would I go about doing this with UIToolkit for runtime?