diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 9140da2f8..508fbe446 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -444,6 +444,13 @@ + + + + Returns [code]true[/code] if the node is ready, i.e. it's inside scene tree and all its children are initialized. + [method request_ready] resets it back to [code]false[/code]. + + diff --git a/scene/main/node.cpp b/scene/main/node.cpp index dd9455333..db070a615 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -3487,6 +3487,10 @@ bool Node::is_displayed_folded() const { return data.display_folded; } +bool Node::is_node_ready() const { + return !data.ready_first; +} + void Node::request_ready() { data.ready_first = true; } @@ -3602,6 +3606,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_free"), &Node::queue_delete); ClassDB::bind_method(D_METHOD("request_ready"), &Node::request_ready); + ClassDB::bind_method(D_METHOD("is_node_ready"), &Node::is_node_ready); ClassDB::bind_method(D_METHOD("set_network_master", "id", "recursive"), &Node::set_network_master, DEFVAL(true)); ClassDB::bind_method(D_METHOD("get_network_master"), &Node::get_network_master); diff --git a/scene/main/node.h b/scene/main/node.h index e5c14c4b3..1e780ae48 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -547,6 +547,7 @@ public: } void reset_physics_interpolation(); + bool is_node_ready() const; void request_ready(); static void print_stray_nodes();