You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-12 13:20:55 +00:00
Merge pull request #78206 from alula/node-count-in-group
Add SceneTree.get_node_count_in_group()
This commit is contained in:
@@ -122,6 +122,13 @@
|
|||||||
Returns the number of nodes in this [SceneTree].
|
Returns the number of nodes in this [SceneTree].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_node_count_in_group" qualifiers="const">
|
||||||
|
<return type="int" />
|
||||||
|
<param index="0" name="group" type="StringName" />
|
||||||
|
<description>
|
||||||
|
Returns the number of nodes assigned to the given group.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_nodes_in_group">
|
<method name="get_nodes_in_group">
|
||||||
<return type="Node[]" />
|
<return type="Node[]" />
|
||||||
<param index="0" name="group" type="StringName" />
|
<param index="0" name="group" type="StringName" />
|
||||||
|
|||||||
@@ -1302,6 +1302,16 @@ bool SceneTree::has_group(const StringName &p_identifier) const {
|
|||||||
return group_map.has(p_identifier);
|
return group_map.has(p_identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SceneTree::get_node_count_in_group(const StringName &p_group) const {
|
||||||
|
_THREAD_SAFE_METHOD_
|
||||||
|
HashMap<StringName, Group>::ConstIterator E = group_map.find(p_group);
|
||||||
|
if (!E) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return E->value.nodes.size();
|
||||||
|
}
|
||||||
|
|
||||||
Node *SceneTree::get_first_node_in_group(const StringName &p_group) {
|
Node *SceneTree::get_first_node_in_group(const StringName &p_group) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
HashMap<StringName, Group>::Iterator E = group_map.find(p_group);
|
HashMap<StringName, Group>::Iterator E = group_map.find(p_group);
|
||||||
@@ -1617,6 +1627,7 @@ void SceneTree::_bind_methods() {
|
|||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_nodes_in_group", "group"), &SceneTree::_get_nodes_in_group);
|
ClassDB::bind_method(D_METHOD("get_nodes_in_group", "group"), &SceneTree::_get_nodes_in_group);
|
||||||
ClassDB::bind_method(D_METHOD("get_first_node_in_group", "group"), &SceneTree::get_first_node_in_group);
|
ClassDB::bind_method(D_METHOD("get_first_node_in_group", "group"), &SceneTree::get_first_node_in_group);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_node_count_in_group", "group"), &SceneTree::get_node_count_in_group);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_current_scene", "child_node"), &SceneTree::set_current_scene);
|
ClassDB::bind_method(D_METHOD("set_current_scene", "child_node"), &SceneTree::set_current_scene);
|
||||||
ClassDB::bind_method(D_METHOD("get_current_scene"), &SceneTree::get_current_scene);
|
ClassDB::bind_method(D_METHOD("get_current_scene"), &SceneTree::get_current_scene);
|
||||||
|
|||||||
@@ -385,6 +385,7 @@ public:
|
|||||||
void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
|
void get_nodes_in_group(const StringName &p_group, List<Node *> *p_list);
|
||||||
Node *get_first_node_in_group(const StringName &p_group);
|
Node *get_first_node_in_group(const StringName &p_group);
|
||||||
bool has_group(const StringName &p_identifier) const;
|
bool has_group(const StringName &p_identifier) const;
|
||||||
|
int get_node_count_in_group(const StringName &p_group) const;
|
||||||
|
|
||||||
//void change_scene(const String& p_path);
|
//void change_scene(const String& p_path);
|
||||||
//Node *get_loaded_scene();
|
//Node *get_loaded_scene();
|
||||||
|
|||||||
Reference in New Issue
Block a user