EventSystem.current.IsPointerOverGameObject
public class TouchExample : MonoBehaviour
{
void Update()
{
// Check if there is a touch
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
// Check if finger is over a UI element
if (EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
Debug.Log("Touched the UI");
}
}
}
}