Skip to content

Commit b297234

Browse files
committed
Merge pull request #92992 from KoBeWi/buy_a_new_camera_every_time_project_settings_change
Update Camera2D gizmos when screen size changes
2 parents fdb6100 + 9f7f180 commit b297234

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

scene/2d/camera_2d.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ void Camera2D::_update_scroll() {
7474
}
7575
}
7676

77+
#ifdef TOOLS_ENABLED
78+
void Camera2D::_project_settings_changed() {
79+
if (screen_drawing_enabled) {
80+
queue_redraw();
81+
}
82+
}
83+
#endif
84+
7785
void Camera2D::_update_process_callback() {
7886
if (is_physics_interpolated_and_enabled()) {
7987
set_process_internal(is_current());
@@ -267,6 +275,14 @@ void Camera2D::_ensure_update_interpolation_data() {
267275

268276
void Camera2D::_notification(int p_what) {
269277
switch (p_what) {
278+
#ifdef TOOLS_ENABLED
279+
case NOTIFICATION_READY: {
280+
if (Engine::get_singleton()->is_editor_hint() && is_part_of_edited_scene()) {
281+
ProjectSettings::get_singleton()->connect(SNAME("settings_changed"), callable_mp(this, &Camera2D::_project_settings_changed));
282+
}
283+
} break;
284+
#endif
285+
270286
case NOTIFICATION_INTERNAL_PROCESS: {
271287
_update_scroll();
272288
} break;

scene/2d/camera_2d.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class Camera2D : public Node2D {
8888
bool _is_editing_in_editor() const;
8989
void _update_process_callback();
9090
void _update_scroll();
91+
#ifdef TOOLS_ENABLED
92+
void _project_settings_changed();
93+
#endif
9194

9295
void _make_current(Object *p_which);
9396
void _reset_just_exited() { just_exited_tree = false; }

0 commit comments

Comments
 (0)