UI buttons don't work with Canvas Render Mode: Screen Space - Camera.

Hi!

I am facing an odd and annoying problem. For some reason UI buttons don’t work when Canvas’ rendering mode is Screen Space - Camera. I need to use this mode because I am displaying some 3D models along with UI elements, that’s why I can’t use Screen Space - Overlay. With Overlay mode buttons work fine, but 3D models are not visible. If I switch the mode at runtime, I will see that buttons are clickable(overlay), non-clickable(camera), clickable(overlay), non-clickable(camera).

  • I do have EventSystem and Standalone
    Mobile Input in my scene.
  • All the UI elements are in front of
    the camera(I tried putting them
    everywhere along Z-axis)
  • I tried setting all possible values
    of Order in Layer.
  • Buttons are on top of the canvas, so
    they are not covered with any other
    UI elements that are raycast targets.

Seems like I’ve tried all possible solutions that are listed in related threads.
Thank you

@Unity3DSupport

Check if have “Graphic Raycaster (Script)” attached to your Canvas.

I had this issue when I had a script that inherited Image and overrode IsRaycastLocationValid. Removing that made it work, so it could be that.