9
votes

I'm using Unity 3D's new UI system to build a pause menu for my game. Currently I'm trying to have my buttons respond to mouse clicks. Some of my hierarchy is as follows:

Canvas hierarchy

When I click on one of my buttons in-game nothing happens, this includes a lack of button animation that should occur when hovering. My "Main Canvas" gameobject contains the following components:

Canvas components

I have already ensured that my Image component has "Raycast target" checked and that my Button component has "Interactable" checked.

Button

Could this be because my Canvas' render mode is in screen space (camera)? I need the render mode to be set to this because I have 3D models that are added in front of the UI during gameplay.

Things I have already tried / checked:

  • Ensured that an EventSystem was present
  • Checked that another UI element wasn't covering the buttons, preventing a raycast
  • Ensured that the camera rendering the UI is above my main camera that is attached to the player. The rendering UI camera has a layer of 1 while the player camera has a layer of 0.
3
What is Menu and What is Menu Items? Are they Buttons too? - Programmer
Menu is simply an empty gameobject used to organize "Menu Items" and "Done". "Menu Items" contains a Vertical Layout Group component that organizes the three menu items. Here is an image of the "Menu Items" gameobject: vgy.me/zBKOg1.png - Walker Christie
This would be hard hard to solve without access to your scene. It could be anything blocking the Button. What Unity version is this? Can you upload the scene to some website then link it here....I will take a look myself. - Programmer
I'm using Unity 5.4.0b21 which is the beta (not the most recently released beta though.) I had to use because a critical bug was fixed in it. I would be happy to upload the scene but with the assets that are used it would be a multiple gigabyte download. Just uploading the .unity file probably wouldn't give enough information, would it? - Walker Christie
Ok. Will take a look. - Programmer

3 Answers

31
votes

Your EventSystem GameObject is missing the Standalone Input Module Script component.

Select your EventSystem->Add Component ->Standalone Input Module. Done!

The gif below decsribes two ways to do that.

enter image description here

4
votes

If anyone here ever runs into this problem and none of these fixes work, go to Edit > project settings > Input, then in the inspector tab click the little gear icon in the top right corner and click Reset. this should fix all your buttons!

1
votes

Ensured that EventSystem component is present in the hierarchy. Without EventSystem unity is not able to track any events that's occurring in the particular scene