diff options
| author | Pedro J. Estébanez | 2017-04-08 12:56:32 +0200 |
|---|---|---|
| committer | Pedro J. Estébanez | 2017-04-08 13:24:29 +0200 |
| commit | c3c0cfd2070c3aec30c1c7dc2392818a8a65ee65 (patch) | |
| tree | 9efa76e23e6ad157b2cf6c918a6f044353c0252b /scene/2d/area_2d.cpp | |
| parent | 990e8e00c7fd743337617679f43bcec5cc773cc6 (diff) | |
| download | godot-c3c0cfd2070c3aec30c1c7dc2392818a8a65ee65.tar.gz godot-c3c0cfd2070c3aec30c1c7dc2392818a8a65ee65.tar.zst godot-c3c0cfd2070c3aec30c1c7dc2392818a8a65ee65.zip | |
Fix side effects of the bookkepping of Area/Area2D's monitoring
- Fix monitoring flag being reset when the scene is out of the tree (happens on save all if the current scene is not the focused one, therefore on save-on-run as well)
- Fix the inability to reset the monitoring flag while the area is out of the tree
Diffstat (limited to 'scene/2d/area_2d.cpp')
| -rw-r--r-- | scene/2d/area_2d.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 1a53f684e..cea9cd8da 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -380,10 +380,6 @@ void Area2D::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_READY: { - - is_ready = true; - } break; case NOTIFICATION_EXIT_TREE: { monitoring_stored = monitoring; @@ -391,16 +387,25 @@ void Area2D::_notification(int p_what) { _clear_monitoring(); } break; case NOTIFICATION_ENTER_TREE: { - if (is_ready) - set_enable_monitoring(monitoring_stored); + + if (monitoring_stored) { + set_enable_monitoring(true); + monitoring_stored = false; + } } break; } } void Area2D::set_enable_monitoring(bool p_enable) { + if (!is_inside_tree()) { + monitoring_stored = p_enable; + return; + } + if (p_enable == monitoring) return; + if (locked) { ERR_EXPLAIN("Function blocked during in/out signal. Use call_deferred(\"set_enable_monitoring\",true/false)"); } @@ -422,7 +427,7 @@ void Area2D::set_enable_monitoring(bool p_enable) { bool Area2D::is_monitoring_enabled() const { - return monitoring; + return monitoring || monitoring_stored; } void Area2D::set_monitorable(bool p_enable) { @@ -651,7 +656,6 @@ Area2D::Area2D() collision_mask = 1; layer_mask = 1; monitoring_stored = false; - is_ready = false; set_enable_monitoring(true); set_monitorable(true); } |
