Can a control node (UI) be set to 'always on top' regardless of where it sits in the tree?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Macryc

Hi. Is it possible to have a UI node not be placed at the bottom of the tree and the buttons still be accessible? For a variety of reasons I have contextual UI elements scattered up and down the tree. I have a node that intercepts mouse clicks. If a UI element is ‘behind’ this node, the elements (buttons) within it aren’t accessible (they do show up but are not clickable). How do i bring them to the ‘front’ without moving the nodes to the bottom of the tree?

:bust_in_silhouette: Reply From: njamster

Create a CanvasLayer-node and set it’s layer-property to a high enough value. Add your UI-node as a child. Any parent-node that has a z_index-property should work as well, but I would say a CanvasLayer is a very intuitive choice for this.

Thanks! It does work with CanvasLayer. I actually already tried the z-index method previously with Node2D but it didn’t work so I assumed that it just doesn’t. But no, it turns out CanvasLayer does the trick. For anyone else reading, it’s not any node with z-index. It has to be CanvasLayer.

Macryc | 2020-04-06 15:44

1 Like