diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/camera_2d.cpp | 12 |
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); } } |