-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Z-index for the Button node? Or... all Control Nodes? #7692
Comments
GUI, like most 2D in Godot, is displayed on tree-order. No index is
provided.
…On Tue, Jan 31, 2017 at 4:19 PM, Qws ***@***.***> wrote:
Why is there no z-index for the Button node, Panel node and I believe all
Control Nodes?
When I press on the button in my game, a panel should be sliding from out
of camera view into the camera view. The panel should be beneath the button
on Z-Index. But instead it overlaps the button.
But for some reason it doesn't has Z-index option. And from the other
controls I've seen, none actually do... is there a particle reason for it?
I'm using Godot 2.1.2 Stable.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#7692>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z20Cgly1bZmAuOTfZLGNgVXDWP63kks5rX4lSgaJpZM4LzEAa>
.
|
Note that you can still set the z-index for controls manually: |
Edit: Adding multiple CanvasLayers Solved my issue I tried I am using Sprites that have a z-index > 0 and the UI should be on top of the sprite but it looks like the z-index from control is 0 and there is no way to change it.
I could probably solve this somehow with all sprites having a z-index<0 but it looks more like a missing feature or bug. |
Sprites are displayed on tree-order, but they have z-index that we can change to fine-tune without too many complications. GUI controls should also have that option. |
Giving my two cents here, but z-index should be a CanvasItem property, not a Node2D one (that way it would be editor configurable for both Control and Node2D). |
Has anything progressed o this topic? |
This would be a nice feature. It adds more flexibility. |
The reason why Z-Index is not exposed in controls is because it won't work
as you expect it to. The control may be displayed on top of other controls,
but as input is handled strictly in tree order, your control won't get
input by being on top of other controls.
If you want it to appear on top of others, use set_toplevel() instead, and
your control will not depend on the parent controls, as well as appearing
on top.
…On Mon, Jun 25, 2018 at 8:36 AM MrHoothoot ***@***.***> wrote:
This would be a nice feature. It adds more flexibility.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7692 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF-Z2-KOfolb3uxXVjjB72en8CfRbtGMks5uAMtFgaJpZM4LzEAa>
.
|
@reduz Is input handling the only reason for such limitation? I personally use lots of Labels and other controls exclusively for their display function while all input is handled higher up in a root node (as that's the only level at which input state becomes relevant). Unless there's a different way to display text that I'm missing, then I think it's quite cumbersome to limit z-sorting of UI elements just because of Input handling as 90% of use cases will be for display-only. |
So, given the following Tree:
When I set a z-index > 0 on Given that Controls are drawn in tree order, shouldn't |
Is there any workaround for this? |
I see this is a long-standing discussion. I'll throw my 2 cents in cause I also found it unintuitive that you can't z-order Controls given they're supposed to be visual elements, apart from Containers. I understand that the reason is input handling. @reduz couldn't we then handle input in z-order and if same z-order in tree order? I was doing something that requires this sort of layout, but I want to then place some nodes on top of others visually. It makes sense to me that they receive input on the visual order too (z-order) more so than tree order, if they were to have a z-order property. When I do say this: func _ready() -> void:
get_child(3).set_as_toplevel(true) It messes it up so that's not an option As a workaround I see if I set edit: and what happens if we want the overlap to go from right to left? At the moment with it can't be achieved, unless done manually. |
If you put Control under Node2D, it will inherit its Z-index. That should be anough in most cases, UI is supposed to go on separate CanvasLayer anyways. |
One issue with the z-index being tied to tree order is that for the various Containers, display position is also tied to tree order. Meaning if you have a Control that moves out of the bounds of its parent Container (say, in an animation), you have to no way of controlling which bordering elements it goes over or under, it will always go over elements to the left and under elements to the right (or above and below). The Node2D solution doesn't work here, because then you lose the formatting of the Container. |
Closing in favor of godotengine/godot-proposals#839, as feature proposals are now tracked on the Godot proposals repository. |
Why is there no z-index for the Button node, Panel node and I believe all Control Nodes?
When I press on the button in my game, a panel should be sliding from out of camera view into the camera view. The panel should be beneath the button on Z-Index. But instead it overlaps the button.
But for some reason it doesn't has Z-index option. And from the other controls I've seen, none actually do... is there a particle reason for it?
I'm using Godot 2.1.2 Stable.
The text was updated successfully, but these errors were encountered: