aboutsummaryrefslogtreecommitdiff
path: root/editor/plugins/texture_region_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2018-03-13 12:53:51 +0100
committerGitHub2018-03-13 12:53:51 +0100
commit8b629bbcbe5da04fed8dd4828b79ca24c0f168e1 (patch)
tree0700355b0f4afd589eac8bb9a623ab2152b56ddf /editor/plugins/texture_region_editor_plugin.cpp
parentfcd81c9627fd9ec13be4ed3ff55d7213b2f7c3ba (diff)
parent86938a06aaad69669b482c589840961ce1509cdc (diff)
downloadgodot-8b629bbcbe5da04fed8dd4828b79ca24c0f168e1.tar.gz
godot-8b629bbcbe5da04fed8dd4828b79ca24c0f168e1.tar.zst
godot-8b629bbcbe5da04fed8dd4828b79ca24c0f168e1.zip
Merge pull request #17166 from Noshyaar/tilemap2
TileSet&TextureRegion: fix error when getting nonexistent tile
Diffstat (limited to 'editor/plugins/texture_region_editor_plugin.cpp')
-rw-r--r--editor/plugins/texture_region_editor_plugin.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp
index 6cb4ca1e8..8272ec2ef 100644
--- a/editor/plugins/texture_region_editor_plugin.cpp
+++ b/editor/plugins/texture_region_editor_plugin.cpp
@@ -57,8 +57,9 @@ void TextureRegionEditor::_region_draw() {
base_tex = obj_styleBox->get_texture();
else if (atlas_tex.is_valid())
base_tex = atlas_tex->get_atlas();
- else if (tile_set.is_valid() && selected_tile != -1)
+ else if (tile_set.is_valid() && selected_tile != -1 && tile_set->has_tile(selected_tile))
base_tex = tile_set->tile_get_texture(selected_tile);
+
if (base_tex.is_null())
return;
@@ -688,10 +689,11 @@ void TextureRegionEditor::_edit_region() {
texture = obj_styleBox->get_texture();
else if (atlas_tex.is_valid())
texture = atlas_tex->get_atlas();
- else if (tile_set.is_valid() && selected_tile != -1)
+ else if (tile_set.is_valid() && selected_tile != -1 && tile_set->has_tile(selected_tile))
texture = tile_set->tile_get_texture(selected_tile);
if (texture.is_null()) {
+ edit_draw->update();
return;
}
@@ -780,6 +782,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) {
tile_set = Ref<TileSet>(NULL);
editor = p_editor;
undo_redo = editor->get_undo_redo();
+ selected_tile = -1;
snap_step = Vector2(10, 10);
snap_separation = Vector2(0, 0);