diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-05 16:05:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 16:05:53 +0100 |
commit | aecff478b71ccc4b8a6017ea896563fb0a95c002 (patch) | |
tree | d963e7a0567b16aa623fabd156044e15db8db38d /editor/scene_tree_editor.cpp | |
parent | 69d7d1ec52c610a618265e48f26bd3d4bb1a1083 (diff) | |
parent | 189dab2d765dcc9ad74e7392fa0b239ea70a9513 (diff) |
Merge pull request #48006 from KoBeWi/incognito_layer
Add visibility to CanvasLayer
Diffstat (limited to 'editor/scene_tree_editor.cpp')
-rw-r--r-- | editor/scene_tree_editor.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index c755bca64f..fcb4f5b32e 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -362,6 +362,17 @@ bool SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent, bool p_scroll } _update_visibility_color(p_node, item); + } else if (p_node->is_class("CanvasLayer")) { + bool v = p_node->call("is_visible"); + if (v) { + item->add_button(0, get_theme_icon("GuiVisibilityVisible", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + } else { + item->add_button(0, get_theme_icon("GuiVisibilityHidden", "EditorIcons"), BUTTON_VISIBILITY, false, TTR("Toggle Visibility")); + } + + if (!p_node->is_connected("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed))) { + p_node->connect("visibility_changed", callable_mp(this, &SceneTreeEditor::_node_visibility_changed), varray(p_node)); + } } else if (p_node->is_class("Node3D")) { bool is_locked = p_node->has_meta("_edit_lock_"); if (is_locked) { @@ -471,6 +482,9 @@ void SceneTreeEditor::_node_visibility_changed(Node *p_node) { 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")) { + visible = p_node->call("is_visible"); + CanvasItemEditor::get_singleton()->get_viewport_control()->update(); } else if (p_node->is_class("Node3D")) { visible = p_node->call("is_visible"); } @@ -514,7 +528,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")) { + if (p_node->is_class("Node3D") || p_node->is_class("CanvasItem") || p_node->is_class("CanvasLayer")) { 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)); } |