diff --git a/editor/plugins/tiles/tile_atlas_view.cpp b/editor/plugins/tiles/tile_atlas_view.cpp index fd651dd5072..43c6d1a48b1 100644 --- a/editor/plugins/tiles/tile_atlas_view.cpp +++ b/editor/plugins/tiles/tile_atlas_view.cpp @@ -404,13 +404,16 @@ void TileAtlasView::_draw_background_right() { } void TileAtlasView::set_atlas_source(TileSet *p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { - ERR_FAIL_COND(!p_tile_set); - ERR_FAIL_COND(!p_tile_set_atlas_source); + tile_set = p_tile_set; + tile_set_atlas_source = p_tile_set_atlas_source; + + if (!tile_set) { + return; + } + ERR_FAIL_COND(p_source_id < 0); ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source); - tile_set = p_tile_set; - tile_set_atlas_source = p_tile_set_atlas_source; source_id = p_source_id; // Show or hide the view. diff --git a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp index 912fdb03a92..e56541b50d7 100644 --- a/editor/plugins/tiles/tile_set_atlas_source_editor.cpp +++ b/editor/plugins/tiles/tile_set_atlas_source_editor.cpp @@ -120,10 +120,9 @@ void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::_bind_methods() { } void TileSetAtlasSourceEditor::TileSetAtlasSourceProxyObject::edit(Ref p_tile_set, TileSetAtlasSource *p_tile_set_atlas_source, int p_source_id) { - ERR_FAIL_COND(!p_tile_set.is_valid()); ERR_FAIL_COND(!p_tile_set_atlas_source); ERR_FAIL_COND(p_source_id < 0); - ERR_FAIL_COND(p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source); + ERR_FAIL_COND(p_tile_set.is_valid() && p_tile_set->get_source(p_source_id) != p_tile_set_atlas_source); if (p_tile_set == tile_set && p_tile_set_atlas_source == tile_set_atlas_source && p_source_id == source_id) { return; @@ -611,6 +610,10 @@ void TileSetAtlasSourceEditor::_update_tile_data_editors() { tile_data_editors_tree->clear(); + if (tile_set.is_null()) { + return; + } + TreeItem *root = tile_data_editors_tree->create_item(); TreeItem *group; @@ -919,6 +922,10 @@ void TileSetAtlasSourceEditor::_update_atlas_view() { alternative_tiles_control->get_child(i)->queue_free(); } + if (tile_set.is_null()) { + return; + } + Vector2i pos; Vector2 texture_region_base_size = tile_set_atlas_source->get_texture_region_size(); int texture_region_base_size_min = MIN(texture_region_base_size.x, texture_region_base_size.y);