Unity Canvas button not working
16,432
Solution 1
The easiest way to debug is to :
- Run the game in the editor, not in full screen (uncheck Maximize On Play button)
- Select the
EventSystem
GameObject of your scene - In the inspector, open the Preview Window and make it big enough
- Move your mouse on your screen, and check if the name of your buttons appear next to the field
pointerEnter
If you can't see it, here are possible solutions :
- Make sure you don't have any UI elements above your button which could block the raycasts
- Make sure you have enabled raycasting on the images used by your buttons (check RaycastTarget)
- Make sure you have an
EventSystem
in your scene - Make sure you have a callback attached to your buttons so as to trigger your functions
- Make sure you don't have any
CanvasGroup
withBlocksRaycast
orInteractable
set to false - Make sure you have a
GraphicRaycaster
attached on a gameobject (on the Canvas usually)
Solution 2
Turns out I did not know that you have add a Graphic Raycaster component as well. Started taking input after that.
Thanks everyone.
![Jajan](https://lh5.googleusercontent.com/-ua8Nb0xtybY/AAAAAAAAAAI/AAAAAAAAA2o/Nfu5GXTZF9A/photo.jpg?sz=256)
Author by
Jajan
Updated on June 19, 2022Comments
-
Jajan about 2 years
I added a canvas component to one of my images to override default layer order sorting. Turns out the button controls on that panel have stopped working?
Has anyone any idea about this in Unity? I am using unity 5.5.2.