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

  • July 17, 2023

    Terrain3D for Godot has been released

    The Terrain3D addon for Godot lets you create and manage 3D terrains within Godot. It looks quite promising for making landscapes, hills, valleys, and other natural environments. The addon provides tools for sculpting the terrain, and you can paint different textures like grass, dirt, or rock, and blend them smoothly. It also supports features like …

  • February 22, 2024

    Inventory System v1.10 available

    We’re excited about this release, which includes a range of quality-of-life additions and refinements. Drag-and-drop support has been improved with a second strategy: Click-and-release: Simply clicking (and releasing) an item will pick it up. This leverages Godot’s force-drag functionality and approximates the drag-and-drop behavior that games like Valheim and Palworld use in their inventory items. …

  • December 22, 2022

    A GDScript refactoring exercise

    Arguably, more fun than writing code is removing code. I was assembling a split-screen multiplayer UI. The goal behavior is to show/hide the appropriate displays for the players, depending on how many players there are. Initially, the code to update the UI was very simple, because I started with two players. In that case, you …

  • January 29, 2024

    Inventory System v1.0 available

    Version 1.0 of the Inventory System is now available. It includes a few new additions since the closed beta: Lots of fixes found their way into this release as well:

    © 2025 GoGoGodot.io. All rights reserved.