0 votes

The issue is that what button the mouse hovers over isn't affected by the z-index value of it's parent node2D and rather just based on the order of the scene tree (buttons drawn last in the scene are hovered over first). The button's texture is affected by it's parent's z_index however, I find this misleading.

I was able to easily test this in a project with 2 node2D nodes with button nodes within them and setting the z_index of the node higher in the scene tree a higher value than the node below it:
overlapping buttons

any suggestions would be appreciated though I might just have to write a function which automatically resizes itself relative to other buttons.

asked Nov 10, 2019 in Engine by KnightNine (60 points)
edited Nov 10, 2019 by KnightNine

1 Answer

0 votes

Whatever GUI node is at the bottom will always be the priority on both rendering and detecting mouse hover/clicks

changing the z-axis will only change the priority on rendering

tho if it's really necessary to have them on top of the scene tree, you can have their sub parent set to canvas layer and change their layer higher than the ones at the bottom (this will complicate your scene tree in the long run)

answered Nov 11, 2019 by LoneDespair (317 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.