diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-02-04 10:13:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-04 10:13:29 +0100 |
commit | 2a3c4f00c892dbee388cda69239285df3e0a41b5 (patch) | |
tree | 75ce59651541d5ffe282db0c89932c0b650077a0 /scene/main | |
parent | b68db2f98aafa9550d683c20a675650613fbc6a6 (diff) | |
parent | fbd9599b04086faefbf9796c41869dddbb6abf37 (diff) |
Merge pull request #57541 from reduz/node-add-remove-hook
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/node.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index a2415442f8..2665a5695b 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -211,6 +211,12 @@ void Node::_propagate_enter_tree() { data.tree->node_added(this); + if (data.parent) { + Variant c = this; + const Variant *cptr = &c; + data.parent->emit_signal(SNAME("child_entered_tree"), &cptr, 1); + } + data.blocked++; //block while adding children @@ -281,6 +287,12 @@ void Node::_propagate_exit_tree() { data.tree->node_removed(this); } + if (data.parent) { + Variant c = this; + const Variant *cptr = &c; + data.parent->emit_signal(SNAME("child_exited_tree"), &cptr, 1); + } + // exit groups for (KeyValue<StringName, GroupData> &E : data.grouped) { @@ -2865,6 +2877,8 @@ void Node::_bind_methods() { ADD_SIGNAL(MethodInfo("tree_entered")); ADD_SIGNAL(MethodInfo("tree_exiting")); ADD_SIGNAL(MethodInfo("tree_exited")); + ADD_SIGNAL(MethodInfo("child_entered_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node"))); + ADD_SIGNAL(MethodInfo("child_exited_tree", PropertyInfo(Variant::OBJECT, "node", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT, "Node"))); ADD_PROPERTY(PropertyInfo(Variant::STRING_NAME, "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_name", "get_name"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "scene_file_path", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "set_scene_file_path", "get_scene_file_path"); |