Skip to content

Commit 6b7829b

Browse files
committed
Fix TileSet not disappearing on deselecting TileMap
1 parent 4714e95 commit 6b7829b

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

editor/plugins/tiles/tiles_editor_plugin.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ void TileMapEditorPlugin::edit(Object *p_object) {
362362
tile_set_plugin_singleton->make_visible(true);
363363
edited_tileset = tile_map->get_tileset()->get_instance_id();
364364
}
365+
} else if (edited_tileset.is_valid()) {
366+
// Hide the TileSet editor, unless another TileSet is being edited.
367+
if (tile_set_plugin_singleton->get_edited_tileset() == edited_tileset) {
368+
tile_set_plugin_singleton->edit(nullptr);
369+
tile_set_plugin_singleton->make_visible(false);
370+
}
371+
edited_tileset = ObjectID();
365372
}
366373
}
367374

@@ -419,6 +426,11 @@ TileMapEditorPlugin::~TileMapEditorPlugin() {
419426

420427
void TileSetEditorPlugin::edit(Object *p_object) {
421428
editor->edit(Ref<TileSet>(p_object));
429+
if (p_object) {
430+
edited_tileset = p_object->get_instance_id();
431+
} else {
432+
edited_tileset = ObjectID();
433+
}
422434
}
423435

424436
bool TileSetEditorPlugin::handles(Object *p_object) const {
@@ -439,6 +451,10 @@ void TileSetEditorPlugin::make_visible(bool p_visible) {
439451
}
440452
}
441453

454+
ObjectID TileSetEditorPlugin::get_edited_tileset() const {
455+
return edited_tileset;
456+
}
457+
442458
TileSetEditorPlugin::TileSetEditorPlugin() {
443459
DEV_ASSERT(tile_map_plugin_singleton);
444460
tile_set_plugin_singleton = this;

editor/plugins/tiles/tiles_editor_plugin.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class TileMapEditorPlugin : public EditorPlugin {
118118
TileMap *tile_map = nullptr;
119119

120120
bool tile_map_changed_needs_update = false;
121-
ObjectID edited_tileset;
121+
ObjectID edited_tileset; // The TileSet associated with the TileMap.
122122

123123
void _tile_map_changed();
124124
void _update_tile_map();
@@ -147,11 +147,15 @@ class TileSetEditorPlugin : public EditorPlugin {
147147
TileSetEditor *editor = nullptr;
148148
Button *button = nullptr;
149149

150+
ObjectID edited_tileset;
151+
150152
public:
151153
virtual void edit(Object *p_object) override;
152154
virtual bool handles(Object *p_object) const override;
153155
virtual void make_visible(bool p_visible) override;
154156

157+
ObjectID get_edited_tileset() const;
158+
155159
TileSetEditorPlugin();
156160
~TileSetEditorPlugin();
157161
};

0 commit comments

Comments
 (0)