summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrBBBaiXue <wch272@outlook.com>2022-04-13 01:50:08 +0800
committerMrBBBaiXue <mrbbbaixue@bakneko.com>2022-08-10 00:48:11 +0800
commit296640ab8f6164ae144602e0fb095b1c16465873 (patch)
tree54932ae16d280c365d72e00b654df11ebcd22d0a
parentc2eaaef1497f8ad557aea9a14e2b3e0582fcfe54 (diff)
Add a way to filter nodes by type.
Add a way to filter nodes by type. Usage: type:NodeType or t:NodeType Co-Authored-By: Haoyu Qiu <timothyqiu@users.noreply.github.com>
-rw-r--r--editor/scene_tree_editor.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp
index ad83db9b60..9a5ed7168f 100644
--- a/editor/scene_tree_editor.cpp
+++ b/editor/scene_tree_editor.cpp
@@ -602,7 +602,9 @@ bool SceneTreeEditor::_update_filter(TreeItem *p_parent, bool p_scroll_to_select
}
if (!keep) {
- keep = filter.is_subsequence_ofn(p_parent->get_text(0));
+ StringName node_type = get_node(p_parent->get_metadata(0))->get_class();
+ bool is_kept_by_type = (filter.begins_with("type:") && filter.trim_prefix("type:").is_subsequence_ofn(node_type)) || (filter.begins_with("t:") && filter.trim_prefix("t:").is_subsequence_ofn(node_type));
+ keep = (filter.is_subsequence_ofn(p_parent->get_text(0)) || is_kept_by_type);
}
p_parent->set_visible(keep);