Merge pull request #86387 from jsjtxietian/fix-tile-set

Fix `UndoRedo history mismatch` when creating a new tile atlas
This commit is contained in:
Yuri Sizov 2023-12-22 17:20:08 +01:00
commit 980d55198c

View file

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