summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-02-23 23:21:50 +0100
committerkobewi <kobewi4e@gmail.com>2023-02-24 13:26:31 +0100
commitcf50eb130e33f55f07466f4e1805c7d3395e5522 (patch)
tree5837f9b20f69692ba5b08563096919da9d95c03a /scene/2d
parente930c8d3838280e40baabc4426bd8236f7ac50a3 (diff)
Fix custom viewports in Camera2D
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/camera_2d.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp
index f7d2ae7d2d..2b90a3702f 100644
--- a/scene/2d/camera_2d.cpp
+++ b/scene/2d/camera_2d.cpp
@@ -414,15 +414,19 @@ Camera2D::Camera2DProcessCallback Camera2D::get_process_callback() const {
}
void Camera2D::_make_current(Object *p_which) {
+ if (!viewport || (custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
+ return;
+ }
+
if (p_which == this) {
if (is_inside_tree()) {
- get_viewport()->_camera_2d_set(this);
+ viewport->_camera_2d_set(this);
queue_redraw();
}
} else {
if (is_inside_tree()) {
- if (get_viewport()->get_camera_2d() == this) {
- get_viewport()->_camera_2d_set(nullptr);
+ if (viewport->get_camera_2d() == this) {
+ viewport->_camera_2d_set(nullptr);
}
queue_redraw();
}
@@ -449,7 +453,7 @@ void Camera2D::make_current() {
void Camera2D::clear_current() {
ERR_FAIL_COND(!is_current());
- if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id))) {
+ if (viewport && !(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)) && viewport->is_inside_tree()) {
viewport->assign_next_enabled_camera_2d(group_name);
}
}