Go, Go, Godot!
  • 0

Toggling Visibility of Nested CanvasLayers

November 27, 2024

I had a setup with nested CanvasLayer nodes. Toggling the visibility of the root CanvasLayer doesn’t hide any nested CanvasLayer nodes. My solution was to listen to the visibility_changed signal, find any CanvasLayer child nodes, and apply the same visibility to them.

func _ready() -> void:
	# If the visibility changes, apply it to any nested CanvasLayer nodes.
	visibility_changed.connect(func() -> void:
		find_children("*", "CanvasLayer", true, false).map(func(node: CanvasLayer) -> void:
			node.visible = visible
		)
	)

Posted in Godot.
Share
PreviousInventory System v1.18.1 available (and v2 progress update)
NextInventory System v1.18 available

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Related Posts

  • March 11, 2025

    Update all resources after modifying a resource class

    Godot’s resources are quite powerful. However, modifying a resource class doesn’t automatically update any corresponding .tres files, unless you happen to edit a scene that uses that resource in some way. This doesn’t impact runtime behavior — the game still runs as expected. But it can impact version control and result in a messier diff …

  • January 3, 2024

    2D Fog Effect Shader Tutorial

    The shader used in the tutorial: https://godotshaders.com/shader/2d-fog-overlay-2/

  • February 29, 2024

    Inventory System v1.12 available

    Crafting is here! The latest inventory system version is now available with the following features: The bug fixes:

  • August 3, 2022

    Share your Computer’s Mouse and Keyboard with your Steam Deck

    I use an app called barrier. It allows you to share your mouse and keyboard with multiple devices. I use it, because I tend to have my laptop and Macbook sitting next to my PC, and it makes working across all devices very convenient. It’s a mix of a multi-monitor and multi-computer setup. Concept Your …

    © 2025 GoGoGodot.io. All rights reserved.