Skip to content

Commit

Permalink
Merge pull request #72550 from KoBeWi/camera_of_the_end
Browse files Browse the repository at this point in the history
Fix Camera2D crashes
  • Loading branch information
akien-mga committed Feb 2, 2023
2 parents 0a9e6e4 + 724d658 commit b4a6dcc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit b4a6dcc

Please sign in to comment.