summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2022-09-12 14:47:24 +0200
committerkobewi <kobewi4e@gmail.com>2022-12-02 00:05:02 +0100
commit7e2a8afb57f59ec70bac6259f186887d953a1eed (patch)
treed891231365e4e7f1b697f47eaaea26c62409ec3a /scene/main/viewport.cpp
parent1e3919c409fa1f24db8ecde58f723fd59adfeccb (diff)
Rework how current Camera2D is determined
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index fdbcb20d30..33ec222da3 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1048,6 +1048,25 @@ Transform2D Viewport::get_final_transform() const {
return stretch_transform * global_canvas_transform;
}
+void Viewport::assign_next_enabled_camera_2d(const StringName &p_camera_group) {
+ List<Node *> camera_list;
+ 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);
+ if (cam->is_enabled()) {
+ new_camera = const_cast<Camera2D *>(cam);
+ break;
+ }
+ }
+
+ _camera_2d_set(new_camera);
+ if (!camera_2d) {
+ set_canvas_transform(Transform2D());
+ }
+}
+
void Viewport::_update_canvas_items(Node *p_node) {
if (p_node != this) {
Window *w = Object::cast_to<Window>(p_node);