As I've spent most of the afternoon working on this and others in this forum have asked about this type of issue, here is one example of how to deal with mouse click RayCast ignoring the UI Toolkit overlay (using 2021.3 / UI Toolkit / New Input System):
Mouse click UI check passthrough.
Code (CSharp):
- private NavMeshAgent _navMeshAgent;
- private void Start()
- {
- // Find main UI overlay
- VisualElement rootUIMain = FindObjectOfType<UIDocument>().rootVisualElement;
- // Register mouse down event on root of UI...