summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Roudière <gilles.roudiere@gmail.com>2021-09-27 14:05:39 +0200
committerGitHub <noreply@github.com>2021-09-27 14:05:39 +0200
commita98453670c8afd33af779782bfa904f838f13e43 (patch)
tree18d518b3dc0e8999d9a45be40a88e80def8a0b55
parent1ae922a829238bf24c60ca3b1dfb28afecda2b14 (diff)
parent140b54fd35eda5e15bbcde36ca1e0aa6d7204493 (diff)
Merge pull request #53100 from KoBeWi/fix_them_tiles_2-layer_count_of_oblivion
Fix TileMap layer loading
-rw-r--r--scene/2d/tile_map.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp
index 03db9c0d32..929233e4e0 100644
--- a/scene/2d/tile_map.cpp
+++ b/scene/2d/tile_map.cpp
@@ -2034,10 +2034,22 @@ bool TileMap::_set(const StringName &p_name, const Variant &p_value) {
return false;
} else if (components.size() == 2 && components[0].begins_with("layer_") && components[0].trim_prefix("layer_").is_valid_int()) {
int index = components[0].trim_prefix("layer_").to_int();
- if (index < 0 || index >= (int)layers.size()) {
+ if (index < 0) {
return false;
}
+ if (index >= (int)layers.size()) {
+ _clear_internals();
+ while (index >= (int)layers.size()) {
+ layers.push_back(TileMapLayer());
+ }
+ _recreate_internals();
+
+ notify_property_list_changed();
+ emit_signal(SNAME("changed"));
+ update_configuration_warnings();
+ }
+
if (components[1] == "name") {
set_layer_name(index, p_value);
return true;