From c674fcd9653887f3a143111f547aa7170e7e6f67 Mon Sep 17 00:00:00 2001 From: Torsten Date: Wed, 5 Nov 2025 05:29:51 +0100 Subject: [PATCH] Godot TileMapLayer => TileSet Logic --- .../Get Atlas from TileSet in TileMapLayer.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 MyObsidianVault/Knowledgebase/Godot/2D/Get Atlas from TileSet in TileMapLayer.md diff --git a/MyObsidianVault/Knowledgebase/Godot/2D/Get Atlas from TileSet in TileMapLayer.md b/MyObsidianVault/Knowledgebase/Godot/2D/Get Atlas from TileSet in TileMapLayer.md new file mode 100644 index 0000000..0dd60f6 --- /dev/null +++ b/MyObsidianVault/Knowledgebase/Godot/2D/Get Atlas from TileSet in TileMapLayer.md @@ -0,0 +1,24 @@ +```gdscript +func display_layer_data(): + # Assume TileMapLayer node is referenced as 'tile_map_layer' + var tile_set = self.tile_set + + # Get the number of TileSetSources (sources in tileset) + var source_count = tile_set.get_source_count() + + print("Number of sources in TileSet: ", source_count) + + # Iterate over all sources in the tileset + for i in range(source_count): + var source_id = tile_set.get_source_id(i) # integer ID of source (atlas source) + + # Get the source resource + var source = tile_set.get_source(source_id) + + # Check if this source is an Atlas type source + if source is TileSetAtlasSource: + print("Found Atlas Source ID: ", source_id) + print("Atlas Grid Size: ", source.get_atlas_grid_size()) + # You can now use this source_id as the valid atlas source ID assigned to the TileMapLayer +``` +