World Space Unity.UI Buttons

So, I’ve been working with the new Unity.UI recently and clearly I still don’t get it. Sometimes when I add a button to a canvas it works great. Other times I get no input. When this occurs there is no good way at all to figure out what is going on. Frankly, Unity.UI is the most disappointing feature Unity has released because of these issues. Right, that’s the end of the rant. Now my problem.

I have a canvas attached to a game object. The canvas is a world space canvas with multiple buttons and texts on it. None of my buttons receive input when I click them. Even if I drop a default button onto them, nothing works.

However, if I create a new canvas with a button on it everything works as expected. What is going on here? Why are some working and some not working? How am I supposed to go about debugging these kind of things?

My camera, event system etc. are all configured properly at least as far as I can tell.

Right, I got it sorted out. When you add a Canvas via the “Add Component” menu it does not add the Graphic Raytracer component that is required for input for buttons etc to work. After adding this I needed to also update the scale of my UI as the raytracer would only work with positive scales (if at any time one of my scales was negative, X in this case, everything would break and I wouldn’t see mouse events). After fixing both of those I was able to get input on my buttons.

Here is my updated checklist of debugging tips if your Button/UI is not receiving input. Hopefully someone else will find them useful:

  • Check your Canvas. If your UI is in World Space have you specified the proper Camera?
  • Does the UI component with your canvas attached also have an enabled Graphic Raycaster attached? If you add UI components via the GameObject menu this will be done for you, it is not if you use Add Component from the inspector. If not you can add one via Add Component > Event > Graphic Raycaster.
  • Double check your camera. Is it the correct one?
  • Does your Graphic Raycaster have any new Blocking Objects/Masks specified. Does it work if you disable them?
  • Check your Canvas’s scale. Is it negative? If so, is your Graphic Raycaster set to Ignore Reversed Graphics?
  • Check your hierarchy. Are their objects above the one you are attempting to click that might be capturing the Click or other event?

If I may add to your checklist @Runewake.

  • Check if other UI components within the canvas have “Raycast Targets” set to disabled if there won’t be any interaction with them.

I went through your check list and still had issues until I disabled Raycast Target for the other components.

For me it was my first person character collider that got in the way.

I’m still struggling with this issue. I’m observing a screen-position dependence to the function of the buttons. If a button is in the bottom part of the screen, it doesn’t work. If I move that same button up to the top part of the screen, it works just fine. I’ve gone through the awesome checklist you guys provided, but nothing seems to work. I’m not sure why the raycast code would be messed up in this way. Has anyone else seen this type of issue?

@Runewake: many thanks. The last bullet point from your list made me solve my problem.,@Runewake - thanks a lot. The last point on your checklist solved it for me.

I had the Image-Component of the Button disabled because I straight up didn’t want an Image for my Button. Turns out you need to have the Image-Component enabled with “Raycast Target” checked and on the Button-Component check “Interactable”.

For me the problem was a TextMeshPro on another canvas blocking the raycast. To troubleshoot this, try disabling all other canvases in the scene to see if one is in the way.