TilesetTextureSetter.gd 416 B

123456789101112131415161718192021
  1. class_name TilesetTextureSetter
  2. extends Node
  3. @export var tile_map: TileMapLayer
  4. @export var texture: Texture = null:
  5. set(value):
  6. texture = value
  7. texture_changed.emit()
  8. signal texture_changed
  9. @export var atlas_id := 0
  10. func _ready() -> void:
  11. update()
  12. texture_changed.connect(update)
  13. func update() -> void:
  14. var source = tile_map.tile_set.get_source(atlas_id)
  15. if source != null:
  16. source.texture = texture