I'm working on 2019.4.9f1 on a 2D project using Universal Rendering Pipeline. The camera settings changed so I'm stating it.

I wrote a OnMouseEnter and OnMouseExit in a script to manage whenever my mouse cursor is on top of a SpriteRenderer with a collider located at 0,0,0. I have a main camera located at 0,0,-10. I've tested the script that manages the OnMouse events. It works fine.

Problem: But the moment I add a new camera (UI Camera set to Overlay located at 0,0,-10) in and it is enabled, OnMouse events aren't getting called. Disabling the UI camera makes the OnMouse events work normally.

Solutions that have failed:

  1. I've tried setting the tag of the UI Camera to MainCamera and set Main Camera's tag to Default. https://answers.unity.com/questions/241334/onmousedown-w-multiple-cameras-doesnt-work-right.html
  2. I tried making the UI Camera a bit closer to the sprites. https://answers.unity.com/questions/425478/onmousedown-not-firing.html

I intend to avoid Raycasting and get the OnMouse Events to work because I want to fix the problem and not work around it.

Question: Any possible reason why my OnMouse events aren't called?

  • \$\begingroup\$ "I intend to avoid Raycasting" I have some bad news for you about how the OnMouse events work then. They're still raycasting under the hood, they're just using the most inefficient raycast possible because the engine can't guess what you want and has to cover the widest possible set of use cases. Removing your OnMouse events and firing your own ray will allow you to get finer control over how the events are called and the performance of the testing. \$\endgroup\$
    – DMGregory
    Sep 30, 2020 at 19:45
  • \$\begingroup\$ I see. I guess it can't be helped. Though, how can I reliably check for a 2D object that is directly below my cursor. I've checked answers.unity.com/questions/596792/… and it says to add a 3D collider for a raycast to work. is this necessary or is there a better way of doing it? \$\endgroup\$ Oct 1, 2020 at 0:32
  • 1
    \$\begingroup\$ Presumably you considered Camera.ScreenToWorldPoint and Physics2D.OverlapPoint? \$\endgroup\$
    – DMGregory
    Oct 1, 2020 at 0:36
  • \$\begingroup\$ Oh. Just tested ScreenToWorldPoint while I scrolled through the link. this works. didn't know they existed. \$\endgroup\$ Oct 1, 2020 at 0:42
  • \$\begingroup\$ For future reference, I'm adding the issue tracker for this problem here (tldr there's no formal solution but a few workarounds): issuetracker.unity3d.com/issues/… \$\endgroup\$
    – ido
    May 6, 2022 at 8:36

2 Answers 2


I found a workaround for those interested.

Before setting your overlay camera to overlay, head to rendering - priority, and set to a number lower than your main camera. After that, you may change render type back to overlay.


Simply set main camera priority to a higher number.

  • \$\begingroup\$ This solution worked best in my case as well. \$\endgroup\$
    – ido
    May 6, 2022 at 8:35

same issue here, my setup is

  • base camera with two overlays
  • one of them is rendering only UI (UICamera)
  • the UI Canvas render mode is "Screen Space - Camera" and the Render Camera is set to the UICamera

in my case the solution was to set the Canvas "Plane distance" greater then 0 (actually i guess something greater needed than the camera clipping plane near value)

hope this helps someone too


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .