Godot: CanvasItems nodes do not inherit visibility from their Spatial parents

Created on 23 Sep 2018  路  7Comments  路  Source: godotengine/godot

Godot version: 3.0.6 official

OS/device including version: -

Issue description:

parent visible flag is not applied to every child, what i expected it is applied to every child

Steps to reproduce:
1 create scene
2 add spatial as root
3 add meshinstance as child of spatial the mesh data can be any mesh, set any material
4 add label as child of spatial set to center viewport
5 add camera point to mesh make it at center of viewport
5 add script to spatial make the spatial processed by game loop , on process function set visible to false on spatial

Minimal reproduction project: -

discussion enhancement core

Most helpful comment

I understand what he's saying. If you have a hierarchy of Spatial nodes such as a mesh under a mesh under a mesh, then you make the root no longer visible then the entire hierarchy will shut off. However, if you put a Canvas Item based node nested under all of those meshes it would be visible even though all of the Spatial nodes above it aren't.

IE. If you nested them like this:

  • Spatial (make this not visible)

    • Mesh Instance (this will no longer appear either)

  • - - Mesh Instance (this will no longer appear either)
  • - - - Label (this still shows)

Likewise, if you have a nested hierarchy of Canvas Item nodes, but put a Spatial node inside of all of it and turn off the root Canvas Item node all other canvas item nodes will no longer be visible, but the Spatial one will still be visible.

  • CanvasItem (make this not visible)

    • Button (this will no longer appear either)

  • - - Label (this will no longer appear either)
  • - - - Mesh Instance (this still shows)

I personally like the idea of all nodes with a visibility property to behave consistently. IE. A Canvas Item no longer being visible if it's parent is a Spatial but is no longer visible. While this probably wouldn't break many projects, it's still a breaking change and would at the very least need to be pushed off to 3.2 if this change is desired by others :)

All 7 comments

I really don't understand what the issue is. Each node has their own visibility property that can be true even if a parent is not visible. The node will be hidden because its parent is hidden, but that doesn't affect their own visible property value (otherwise it would be impossible, or at least very hard, to keep a node hidden when enabling visibility on their parent).

add script to spatial make the spatial processed by game loop , on process function set visible to false on spatial

I don't understand this step. It would be simpler if you just put the script code or attach a sample project.

No, the flag is not supposed to be set on all children, that is an expected bahaviour.

To check if a node is visible according to its parents, you can use the is_visible_in_tree() function though.

i just think it is weird because why only mesh instance is not visible but the label is visible after i am setting the spatial visibility to false.

I understand what he's saying. If you have a hierarchy of Spatial nodes such as a mesh under a mesh under a mesh, then you make the root no longer visible then the entire hierarchy will shut off. However, if you put a Canvas Item based node nested under all of those meshes it would be visible even though all of the Spatial nodes above it aren't.

IE. If you nested them like this:

  • Spatial (make this not visible)

    • Mesh Instance (this will no longer appear either)

  • - - Mesh Instance (this will no longer appear either)
  • - - - Label (this still shows)

Likewise, if you have a nested hierarchy of Canvas Item nodes, but put a Spatial node inside of all of it and turn off the root Canvas Item node all other canvas item nodes will no longer be visible, but the Spatial one will still be visible.

  • CanvasItem (make this not visible)

    • Button (this will no longer appear either)

  • - - Label (this will no longer appear either)
  • - - - Mesh Instance (this still shows)

I personally like the idea of all nodes with a visibility property to behave consistently. IE. A Canvas Item no longer being visible if it's parent is a Spatial but is no longer visible. While this probably wouldn't break many projects, it's still a breaking change and would at the very least need to be pushed off to 3.2 if this change is desired by others :)

However, if you put a Canvas Item based node nested under all of those meshes it would be visible even though all of the Spatial nodes above it aren't.

Indeed, the issue is clearer that way. I'll re-open and change the issue title.

Why close?

Agreed, should this have been closed?

Was this page helpful?
0 / 5 - 0 ratings