Inspect selected node in isolation

Godot Version

4.3.dev1

Question

Is there a way to highlight the selected node in the viewport or to hide all other nodes except for the selected node and its children?

Something like “Toggle Visibility” but only for the unselected nodes?

simplest solution would be sth like this:

var highlighted_node: Node
var highlight_old_z_index: int
var highlight_rect: ColorRect

func highlight_node(node):
 highlighted_node = node
 highlight_old_z_index = highlighted_node.z_index
 get_highlight_background()
 highlighted_node.add_child(highlight_rect)
 highlighted_node.z_index = 1,000,000 # comma gets ignored by engine

func get_highlight_background():
 highlight_rect = ColorRect.new()
 highlight_rect.global_position = Vector2(-1000, -1000)
 highlight_rect.rect_size = Vector2(2000, 3000) # to cover 1080p Window
 highlight_rect.show_behind_parent = true
 highlight_rect.modulate = Color(0, 0, 0, 0.5) # slightly opaque black

func hide_highlight():
 highlight_rect.queue_free()
 highlighted_node.z_index = highlight_old_z_index

If the node you want to highlight is a type of Rect (or Label), node color in tree GREEN, then you have to set the z_index via a Node2D type parent node