where would i put that? i already tried it in the camera update but it catches every mouse down, even ones going to the gameobjects, and that’s not what i want
Probably the simplest way to solve that would be to not use OnMouseDown, but use raycasting instead. (OnMouseDown is doing raycasting behind the scenes anyway.) So you do
if GetMouseButtonDown
do raycast
if raycast hits
interact with hit object
else
clicked outside gameobjects
It’s actually easier and more efficient to do what I suggested. Putting a collider behind things can work in specific cases, where the camera basically doesn’t move much.
If you are using OnMouseDown, then yes. However as soon as you add in the UI system then I find it easier to direct all of the clicks through the EventSystem.
The EventSystem is open source. So you can break it open to provide an event if no objects are clicked on.
A camera space UI element at the edge of the far clipping plane will work.