-
-
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
CanvasLayer Child Controls Z-Index Layering Issue #81257
Comments
I'm not sure but this might be intended behaviour because the ordering works as you expect if using a Control or Node2D instead of a canvas layer. |
Please have a look at the description of It explicitly states, that
If I understand you correctly, you want to intermix the drawing hierarchy of CanvasItems in different CanvasLayers. As a solution, it would be best to describe the current behavior better in the docs: |
Is there a specific reason or piece of functionality that means you have to use CanvasLayer and not a Node2D or Control node? |
This is because the maximum z-index is 4096, and in my game, each map has 8 layers. For example, some tiles need to be placed in each layer, and there may be thousands of textures in each layer. So, if I use the formula layer*1000 + texture z-index, it might not be enough, as I have a large number of map textures. Therefore, I adopted the implementation of CanvasLayer. However, it seems that Godot may lack the ability to handle hierarchical rendering order among multiple layers, and it cannot achieve this functionality. This could be an area that needs improvement because there might be a demand for arranging the display order of CanvasLayer child controls within multiple identical layers. From the documentation, it appears that the current Godot implementation is lacking in this aspect. |
I agree, I believe that Godot currently lacks the ability to handle the hierarchical rendering order of CanvasItems across different CanvasLayers. I think Godot needs to enhance this functionality within CanvasLayers. While this usage scenario may be relatively less common, there is still a need for managing the drawing order of CanvasItems across mixed CanvasLayers. If this functionality cannot be achieved, it should indeed be documented to describe the current behavior. |
So it seems that the point of a canvas layer is to completely separate rendering so one layer is behind another no matter their children's z indices. If this were not the case, and you could use the z index to "mix" between the layers, then you that would defeat the purpose of the CanvasLayer, as they would share the same 4096 z indices. It seems that your problem is that you don't have enough z indices. To fix this you could: Put some images on the same z index but just order them using their order in the tree. Use negative z indices. Render some parts that don't change as an image and use that is your game. Godot could: Add more z indices (propbably not necessary). Add some named sorting layers, but this would be the same as using canvas layers. |
I have created a PR for the documentation change in #81270.
it would probably be better, to discuss these in the feature proposal repository https://github.com/godotengine/godot-proposals/ |
Godot version
4.0.3
System information
Windows -Godot 4.0.3
Issue description
I need to change the rendering order of controls within the same Layer, but when I use two CanvasLayer nodes with the same Layer and place controls inside them, changing the z-index of child components does not affect their rendering order. I believe this may be incorrect; within the same layer, I should be able to change a control's z-index to alter its rendering order.
Steps to reproduce
Minimal reproduction project
demo.zip
The text was updated successfully, but these errors were encountered: