- Home /
Unity 4.6 Buttons not responding in second canvas?
I created a second canvas that contains a button, but this button doesn't respond to touch. It just behaves like a static image. How can I work around that or is this by design? The Event System is there. The two canvas's are on the same level aka siblings.
two canvas in same scene is not problem, did you put anything in front of your button (like image, text, or something)?
Answer by jemonsuarez · Aug 05, 2015 at 02:50 AM
I fixed that issue adding a 'Graphic Raycaster' component to every GameObject with a 'Canvas'. I recommend to manage enabling and disabling event in different Canvases with a CanvasGroup component.
For me was enough to add the Graphic Raycaster just to the second canvas. I'm on Unity 5.3.5p7
Answer by ElectricMonk · Feb 19, 2015 at 11:38 PM
I've run into similar problems. Check that the button has an image attached, also check that you're not raycasting against the back of the button (see the GraphicsRaycaster on the canvas GameObject)
Love it, because you made me look at my Raycaster on the canvas where the button wasn't working. Blocking Objects was set to "All" Thanks
Answer by Mmmpies · Dec 26, 2014 at 09:32 AM
I had the same problem when I first started using the new UI.
A panel or any element really can be completely invisible but still block raycasts.
If both Canvases can be shown together make sure the Canvas you don't want to use is disabled, or at least put a Canvas Group on is and un-tick interactable and blocksRaycast.
On the canvase with the button look for any transform that could block the button. Due to rescaling this may not be obvious so just disable every other element on that canvas until you find the one that's blocking.
Answer by BlackPanda · Dec 26, 2014 at 11:35 AM
Check the draw order of canvases. May be that's what's preventing input events. From this post, it says
The draw order is determine by the z position for Screen Space - Overlay canvas's.
Also, try to play with the Sort Order field of Canvas component of both. I think it behaves the same way as Sprite sorting does.
Answer by purpleshirt · Apr 26, 2016 at 10:00 PM
I was running into a case of 2 canvas's elements interacting strangely. Sometimes the "rear" canvas would interfere/block raycast detection on the "front" canvas, and sometimes not.
In the end I finally noticed and used the PRIORITY property in the Graphic Raycaster script to resolve the issue. Priority works such that lower numbers get priority over higher numbers. A priority 1 graphic raycaster will register, for example, a MouseEnter event over a priority 2 graphic raycaster. Incidentally this seems to be the most direct way to control ray caster interactions.
I tried all the other methods in this thread to try to decide which order recasts would be detected and this directly affected the results regardless of the sorting layers etc.
I tried to essentially push the rear canvas back so that my game would register raycasting to the front canvas whenever it overlapped the rear canvas. As per the ideas in this thread I tried varying the Canvas Sorting Layer and Order in Layer on the Canvas component in the inspector as altering Blocking Mask and Blocking Objects values in the Graphics Raycaster component. Neither of these seemed to affect the behavior. I tried adding the Canvas Group component and playing with the Interactable and Blocks Raycasts toggles, but they both resulted in the loss of raycast detection entirely on the rear canvas I was altering. None of these things worked, but setting priorities did.
Hope this helps someone else in my situation.
Your answer
![](https://koobas.hobune.stream/wayback/20220613174814im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
New UI buttons not working on top of screen on iOS devices. 3 Answers
How can I break an UIText on OnClick of an button without scripts ? 2 Answers
Unity UI 4.6 Canvas Enable/Disable make Accessible 2 Answers
Can't click or highlight a button. 0 Answers
Use UI buttons with Time.timeScale=0? 3 Answers