Back to Writing
NOTESunityui-toolkitvisibilitycsharpgame-dev

Unity UI Toolkit - Controlling Element Visibility

October 28, 2022Updated Feb 17, 2026

![](

lcAVq-rkEyaOZkNVOcg.vURRiP4JnXP2lKHzQd1tPcOXB06BLjyxRgfnIYQTLk8g.PNG.cdw0424/image.png?type=w966)

You can access the style and set the visibility as shown above.

The most intuitive approach in this case would be using style.visibility.

However, when creating UI dynamically from code, if you don't initialize this value, it shows up as Null, and you can't use the getter initially.

(Feels like Unity missed this one. It'll probably get patched soon.)

![](

HqsrZNVO4A-XsKap_4g.qcRBrl7f8B2Fq7kZml18pI-lQtKUpAyuxw0Xzdzkq7sg.PNG.cdw0424/image.png?type=w966)

Using visible, you can directly set it to true or false.

Still, it's better to use style.visibility for future compatibility.

I really wish Unity would unify these approaches into one...