浏览代码

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 <[email protected]>
MrBBBaiXue 3 年之前
父节点
当前提交
296640ab8f
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      editor/scene_tree_editor.cpp

+ 3 - 1
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);