Topic was automatically imported from the old Question2Answer platform.
Asked By
Lebostein
Hi,
I know I can check the node parameter Node.visible, but this is useless, if one of the parent nodes becomes invisible. Then all childs are invisivle too, but the flag .visible remains true.
func _ready() -> void:
# connecting signal and adding nodes as extra arguments so we can check if they are visible
var _ok = get_child(0).connect('visibility_changed', self, '_on_visibility_changed', [[get_child(0)]])
# child node connected as [ node, node.parent, parent.parent , ....]
_ok = get_child(0).get_child(0).connect('visibility_changed', self, '_on_visibility_changed', [[get_child(0).get_child(0), get_child(0),]])
func _on_visibility_changed(nodes : Array):
var visibility = true
# check nodes from child to parent and update visibility
for node in nodes:
# if any node is hidden it will stop and changes visibility to false
if node == null: return
if !node.visible:
visibility = node.visible
break
print( "%s visibility = %s" % [nodes[0].name, visibility])