UI Buttons visible but not clickable when using two canvases.


I am having trouble with UI buttons, as they are not clickable. I am using Unity 5.6 with TouchScript 9.0 alpha (though I don’t suspect TouchScript is the problem).

I have two canvases:

One canvas which has screen space: camera. It contains a sidebar with some items. The reason for it having screen space camera is that that made it possible to drag objects from the sidebar into the 3d-world.

Another canvas which contains the not working buttons. The buttons are created from prefabs when a 3d object is tapped. There are three buttons, two of which are “normal” and another which works as a background button (very big, invisible and created before the other buttons, meaning it should be “behind” them). It is used for destroying the other buttons, “closing” the menu.

The problem is that when these buttons appear, they are not clickable. However, the background button is clickable. I have tried for a while to fix this, but there must be something I am missing. I tried creating another button just to test if there was something wrong with the prefabs, but the same thing happens.

Sidebar canvas:

Button canvas:

I could only add two images, but the buttons are the set as interactable and has non-persistent on-click listener which are added in code when they are created.

Does anyone have any idea of what to do? I am thinking the problem might be due to raycasts, but not entirely sure.

Remove raycasting from any button that is not supposed to click. Raycast only hits the first target that is supposed to be hit, the others aren’t hit. I supposed the buttons you want to be clickable are behind the background button.

make both of your canvases to “space camera” mode , then try to change Order In layer;

Add “Graphic Raycaster” component to second Canvas.