- Home /
A Canvas inside a Canvas for the purpose of disabling and enabling menus
I have a scene that has a npc shop. Once the shop activates I want some of the UI elements are activated, there are three buttons and some text. I want to push a button and a bunch of other UI elements, buttons, text, ect. appears below the button. I recently discovered that you can disable the canvas via canvas.enabled = false. I'm using that to enable and disable the shop UI when needed. I'm curious as to if I could create other canvases for the UI associated with the other buttons within the main shop canvas. This way I don't have to disable each UI element individually.
I want to know if this is a decent way to go about doing this, or is it even possible? It seems as though there may be a better way to make a menu like this without creating a new scene and enabling and disabling a lot of UI elements.
Answer by Deathdefy · Oct 10, 2019 at 07:09 PM
It may have changed but from my long term understanding is that it is actually beneficial to have multiple canvi. The whole idea is that when you start selecting buttons or making changes to the UI even if its one object it will dirty your whole canvas and force it to re-draw. Splitting your objects up to turn a parent object on/off is for the most part always beneficial.
Theres quite a few topics floating around about the benefits of multiple canvi, etc. Heres a quick link I found with an explaination.
Your answer
Follow this Question
Related Questions
Scaling a menu bar 1 Answer
Basic question about creating a menu 1 Answer
UI menu not rendering properly 1 Answer
Canvas Button OnClik() 1 Answer
UI doesn't render after scene reload. 0 Answers