How to access TileSetScenesCollectionSource?

Godot Version

4.3.dev1

Question

How can I acces the TileSetScenesCollectionSource of a Tilemap?

What I have here is not working.

extends TileMap


func _ready() -> void:
	print(tile_set.get_scene_tile_scene(0))

You need to get the TileSetScenesCollectionSource resource first with TileSet.get_source()

Example:

extends Node

@onready var tile_map: TileMap = $TileMap

func _ready() -> void:
	var scene_collection = tile_map.tile_set.get_source(0)
	if scene_collection is TileSetScenesCollectionSource:
		for i in scene_collection.get_scene_tiles_count():
			var id = scene_collection.get_scene_tile_id(i)
			var scene = scene_collection.get_scene_tile_scene(id)
			print(scene.resource_path)
2 Likes

Awesome, thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.