Fix VisibilityEnabler2D behavior on start

(cherry picked from commit d0c5d91032)
This commit is contained in:
Tomasz Chabora 2019-09-03 20:22:22 +02:00 committed by Rémi Verschelde
parent 5d26836c78
commit 0200db15cc
1 changed files with 13 additions and 4 deletions

View File

@ -248,10 +248,19 @@ void VisibilityEnabler2D::_notification(int p_what) {
_find_nodes(from); _find_nodes(from);
if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent()) // We need to defer the call of set_process and set_physics_process,
get_parent()->set_physics_process(false); // otherwise they are overwritten inside NOTIFICATION_READY.
if (enabler[ENABLER_PARENT_PROCESS] && get_parent()) // We can't use call_deferred, because it happens after a physics frame.
get_parent()->set_process(false); // The ready signal works as it's emitted immediately after NOTIFICATION_READY.
if (enabler[ENABLER_PARENT_PHYSICS_PROCESS] && get_parent()) {
get_parent()->connect(SceneStringNames::get_singleton()->ready,
get_parent(), "set_physics_process", varray(false), CONNECT_ONESHOT);
}
if (enabler[ENABLER_PARENT_PROCESS] && get_parent()) {
get_parent()->connect(SceneStringNames::get_singleton()->ready,
get_parent(), "set_process", varray(false), CONNECT_ONESHOT);
}
} }
if (p_what == NOTIFICATION_EXIT_TREE) { if (p_what == NOTIFICATION_EXIT_TREE) {