From 42373df2d4a7c7d33ab72b73efe7b01bf43bb609 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Wed, 27 Jul 2022 08:57:37 +0800 Subject: [PATCH] Add a Window visibility toggle button to the Scene tree --- editor/scene_tree_editor.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index 5e1f5ab7503..12f037e4dac 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -390,7 +390,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) { } _update_visibility_color(p_node, item); - } else if (p_node->is_class("CanvasLayer")) { + } else if (p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { bool v = p_node->call("is_visible"); if (v) { item->add_button(0, get_theme_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons")), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); @@ -480,10 +480,7 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { bool visible = false; - if (p_node->is_class("CanvasItem")) { - visible = p_node->call("is_visible"); - CanvasItemEditor::get_singleton()->get_viewport_control()->update(); - } else if (p_node->is_class("CanvasLayer")) { + if (p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { visible = p_node->call("is_visible"); CanvasItemEditor::get_singleton()->get_viewport_control()->update(); } else if (p_node->is_class("Node3D")) { @@ -529,7 +526,7 @@ void SceneTreeEditor::_node_removed(Node *p_node) { p_node->disconnect("script_changed", callable_mp(this, &SceneTreeEditor::_node_script_changed)); } - if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer")) { + if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer") || p_node->is_class("Window")) { if (p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { p_node->disconnect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed)); }