diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index f93b7b0db8a..5425720e103 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -245,6 +245,7 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_ENTER_TREE: { + ERR_FAIL_COND(!is_inside_tree()); canvas = get_canvas(); _setup_viewport(); diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index cee40af0672..87c7bbca142 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -554,6 +554,7 @@ void CanvasItem::_exit_canvas() { void CanvasItem::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { + ERR_FAIL_COND(!is_inside_tree()); first_draw = true; if (get_parent()) { CanvasItem *ci = Object::cast_to(get_parent());