I have an EventSystem.
Tried with the EventSystem option Force Module Active.
I have only one Canvas.
The Canvas has a Graphic Raycaster component.
Canvas Render Mode is set to Screen Space - Overlay, also tried the other two with the camera, didn’t work.
The button is a child object of the Canvas.
The button is marked as interactable and calls a function from a script.
There are no other HUD objects that are at the same place as the button.
I’ve added using UnityEngine.EventSystem; to my script.
Tried putting the button on different places in the hierarchy.
Tried playing the game and restarting Unity a couple of times.
There are a few more things I’ve tried for sure, can’t remember everything at the moment… getting desperate already.
Hmm not sure, tried it now, if I add a Graphic Raycaster to the Camera component, it adds a Canvas component too, which should be on the Canvas GameObject. Also tried variations with this, changing the camera render mode with the Raycaster on Camera, no success once again…
What version of Unity, what OS are you building for? It often helps to narrow down the problem by stripping away everything then slowly adding things back. I would create a new empty test project. Add UI Button to the scene, it should automatically add a Canvas and an Event System. Then Create an Empty Game Object that is a root object in the hierarchy. Create a Script with one Public function called TestButton that just calls Debug.Log(“I’m pressed”). Attach it to your GameObject, then attach the Button’s OnClick to that Function in the editor. Play and press the button and see if you get the Debug Log in the console. I suspect you will.
I’d do all the above with the default settings Unity has for everything. Then change the settings to what your project has. Possibly adding more items and objects from your scene until it stops working.
After a long time I managed to find the problem, although it was already wrong in the tutorials default settings.
If anyone else will have a similar problem, select your Canvas GameObject and look at it’s components. I had the following:
Canvas, Canvas Scaler, Graphic Raycaster, Canvas Group etc…
Select the Canvas Group component and check the boxes of “Interactable” and “Block Raycasts”. It works like a charm now. Thanks everyone for your effort.
I am using Unity 5.5.2 Personal and I’ve recently created a start up scene for my project. I’ve just put 2 UI buttons for which Unity has created a Canvas GameObject. The UI buttons are child of this Canvas.
What I’ve noticed is that by default the Canvas GameObject was created without the raycaster and group components (I don’t remember if there was a scaler component at the initiation of the GameObject).
The solution for me was to add the 2 missing raycaster and group components with their default values (the 2 checkboxes that Sargaxon mentioned above).
Maybe my fault was that I’ve initially created a UI Image and a UI Text object making Unity to create the Canvas without these components. I really don’t know.
Good work! accidentally deleting a component and not knowing which one it was, caused the program to lock up its visual clickable functions. and re adding the component fixes it (Graphic Raycaster) thanks.
So, I had everything working fine. I had my Title menu and game over menu working, but only after I tried to add a pause menu in it, it made only the buttons in the scene I tried to put the pause in stop working. The Title menu works fine, but it doesn’t have a event system or canvas group. I tried copying all the components from the Title menu into that game scene but then they stopped working.
///UPDATE///
After copying the title screen components into the game scene, even though I never altered the title components in the title screen (I just ctrl+c and ctrl+v the canvas into my game scene) they also stopped working. So now no buttons I use work. I have no clue whats wrong, because I didn’t change anything, they just stopped working, and I made sure not to save, so I could go back and hard reset to my last save just in case, but after closing and reopening the project, none of the buttons work, even though Im opening from a file where they still worked.
Same problem for me, as soon as I duplicate a button, all of the others buttons inside my Canvas stopped working… Does anyone have an idea to fix this?
It’s pretty annoying since I have to re-create all the buttons any time I want to add another one.
check your event system item in the editor hierarchy, inside some check boxes are disabled after duplicating an button (thats was the problem at my side).
spent a good 20 minutes running through all the possibilities just to find that i had a 1000 by 1000 clear text object on the top layer that was blocking my button