The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

+1 vote

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.

in Engine by (94 points)
edited by

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)

by (410 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 Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.