summaryrefslogtreecommitdiff
path: root/scene/main
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main')
-rw-r--r--scene/main/viewport.cpp19
-rw-r--r--scene/main/viewport.h1
2 files changed, 20 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);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index bc8cd54603..9afb9cd060 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -512,6 +512,7 @@ public:
Transform2D get_global_canvas_transform() const;
Transform2D get_final_transform() const;
+ void assign_next_enabled_camera_2d(const StringName &p_camera_group);
void gui_set_root_order_dirty();