- Home /
Hidden Canvas, doesn't disable interaction with buttons.
I have set up a canvas, that contains children buttons: Resume, Restart and Quit.
When I press pause, the canvas is enabled, I can click on any button and it works fine. If I resume the game, I disable the canvas, it disappears along with all it's buttons children, but if i click in the place of any of the buttons that disappeared, it executes whatever function they should.
The buttons aren't showing, but I can still press them! why is that?
Answer by bennett_apps · Dec 08, 2018 at 11:48 PM
This doesn't happen for me, how exactly are you "disabling the canvas"? Are you using gameObject.SetActive(false)? Or canvas.enabled = false? Or what?
A few ideas: 1. Try using gameObject.SetActive (false); 2. Try parenting the EventSystem to the canvas 3. Try creating an empty child of the canvas, parenting it to the three buttons, and disabling the parent rather than the entire canvas (using gameObject.SetActive (false);)
@bennett_apps I was referencing the canvas in the code using: public Canvas canvas;
That's why i didn't have the option to use .SetActive(bool)
Now i used: public GameObject canvas; So now i can use .SetActive(bool) and my problem is solved.
Thanks for you help :)
Also note that if you're referencing public Canvas canvas; you can still use setactive by doing: canvas.gameObject.SetActive (false);
No difference really.
Your answer
Follow this Question
Related Questions
Disable and enable canvas group by pressing an UI button. (C#) 2 Answers
Augmented reality - UI - How do I augment an User Interface Canvas properly? 0 Answers
Unity5 UI - How to trigger button click event while preventing menu item deselect event? 1 Answer
Change scene and play it by clicking UI Button? Scene does just load but not start playmode? 1 Answer
Canvas to Canvas In one Scene 1 Answer