Most recently added current Camera2D takes precedence

The situation when multiple current Camera2Ds were in the scene was not dealt with. This could leave several cameras with their current bool set, and each competing to update the viewport scroll, in a random / accidental fashion.

This PR standardises the rule that the most recent current Camera2D added to the scene tree takes over the current status, and sets all other current cameras in the scene tree to non-current. This makes the bools correct, and also prevents the competition over viewport scroll.
This commit is contained in:
lawnjelly 2021-07-03 08:58:20 +01:00
parent 6fe9a0d717
commit 21a24eb959
1 changed files with 6 additions and 2 deletions

View File

@ -245,9 +245,13 @@ void Camera2D::_notification(int p_what) {
canvas = get_canvas();
_setup_viewport();
_update_process_mode();
_update_scroll();
// if a camera enters the tree that is set to current,
// it should take over as the current camera, and mark
// all other cameras as non current
_set_current(current);
first = true;
} break;