Canvas-prefab elements are not interactable

Hello,

My game consists of multiple scenes (levels) and to keep the size more less and to save time, I created a Canvas-prefab since all the UI-elements need to be identical in every level.

For every scene I dragged the Canvas-prefab from the Projects-Tab to the scenes hierachy and added also an EventSystem, respectively.
The references through the scripts are working (e.g. text-elements are updating) but when I want to click on a button or slider it is not possible although its components interactable booleans are set to true and the onClick functions are connected.

However, there is no physical object infront of the canvas, since I have it set on “ScreenSpace - Overlay” and blocking raycasts is set as default to none.

Obviously, only the original Canvas on the first level scene is fully working (for some reason when I open the scene again it is not marked with blue text anymore).

Hmm, so there’s a couple things it might be, but first of all I’m going to recommend something different. If I’m understanding your needs correctly, you need the identical UI in all the scenes? Right? Well we can actually keep using the UI in all the scenes. Just make a script and call it “DontDestroyOnLoad”, attach it to your canvas, then in the Awake method put: DontDestroyOnLoad (transform.gameObject); This will make it so that when you switch scenes, your UI stays around. To get rid of your UI, just call the Destroy() method on it.

If for some reason you can’t do this, here are a couple of reasons that things might not be interacting right.

The first is if Unity thinks there’s something in front of your canvas, even if it’s not visible, that can cause it to block the mouse raycasts and say that there’s another button or object in front of it. Try playing around with the elements in front of it and checking whether they are interactable or block raycasts.

I know I like to sort and control my UI with Canvas groups, which offer you a master control for the alpha, interactability, and raycast blocking of an object and all it’s children. So you can try using that to see if it can help.

Next check that you’re buttons still have the links to the correct functions. I’ve found that a lot of times, prefabs with button’s in them lose the button’s script link, causing the buttons to apparently do nothing. This wouldn’t affect the slider though, suggesting the first one.

The next thing to check is the physical layering of stuff, there are a couple things that will cause things to not be interactable unpredictably. If you’re using the Screen Space - Camera mode (or the World Space with it parented to the camera, don’t do that by the way…), then if you’re UI is behind the camera due to the plane distance, it won’t work. More common, if the back side of your UI is facing the camera, you won’t be able to click on anything by default. Next make sure Blocking Objects is set to None in the Graphic Raycaster, if it’s not, something in the physical world might be blocking it.

Those are all I can think of off the top of my head. But I’ll add more if I can think of them. Good luck in getting this fixed, and if you provide more data on your UI setup, I might be able to help more.

wrapping the prefab in an empty gameobject on the root at 0,0,0 fixed this for me.

Please check, whether you have an Event system in the scene or not. Was it for me.