Fix UndoRedo history mismatch when creating a new tile atlas

This commit is contained in:
jsjtxietian 2023-12-21 17:25:21 +08:00
parent 3ce73e5d41
commit 1217d7d678

View file

@ -117,11 +117,11 @@ void TileSetEditor::_load_texture_files(const Vector<String> &p_paths) {
// Actually create the new source.
Ref<TileSetAtlasSource> atlas_source = memnew(TileSetAtlasSource);
atlas_source->set_texture(texture);
atlas_source->set_texture_region_size(tile_set->get_tile_size());
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
undo_redo->create_action(TTR("Add a new atlas source"));
undo_redo->add_do_method(*tile_set, "add_source", atlas_source, source_id);
undo_redo->add_do_method(*atlas_source, "set_texture_region_size", tile_set->get_tile_size());
undo_redo->add_undo_method(*tile_set, "remove_source", source_id);
undo_redo->commit_action();