diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-02 09:32:41 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-02 09:32:41 +0100 |
commit | b4a6dcc9471b5017c7a617873160bd67550e3f2e (patch) | |
tree | 4e24c00029ccbb204e4604c3789bff947a786e26 | |
parent | 0a9e6e478e3183d7bf3c5cb895c706bc6275d3ea (diff) | |
parent | 724d6581d64d3b8e99dae0bb1011edef8fbf700e (diff) |
Merge pull request #72550 from KoBeWi/camera_of_the_end
Fix Camera2D crashes
-rw-r--r-- | scene/2d/camera_2d.cpp | 6 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 49c5501e77..fe6bee0f1b 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -250,7 +250,7 @@ void Camera2D::_notification(int p_what) { add_to_group(group_name); add_to_group(canvas_group_name); - if (enabled && !viewport->get_camera_2d()) { + if (!Engine::get_singleton()->is_editor_hint() && enabled && !viewport->get_camera_2d()) { make_current(); } @@ -260,11 +260,11 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { + remove_from_group(group_name); + remove_from_group(canvas_group_name); if (is_current()) { clear_current(); } - remove_from_group(group_name); - remove_from_group(canvas_group_name); viewport = nullptr; } break; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c31155bd5c..b0898e2239 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1061,10 +1061,10 @@ void Viewport::assign_next_enabled_camera_2d(const StringName &p_camera_group) { get_tree()->get_nodes_in_group(p_camera_group, &camera_list); Camera2D *new_camera = nullptr; - for (const Node *E : camera_list) { - const Camera2D *cam = Object::cast_to<Camera2D>(E); + for (Node *E : camera_list) { + Camera2D *cam = Object::cast_to<Camera2D>(E); if (cam->is_enabled()) { - new_camera = const_cast<Camera2D *>(cam); + new_camera = cam; break; } } |