How do I change a texture on a tileset without changing the collisions, bitmaps, etc. ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pixelotl

So I have some textures for a tileset that look exactly the same, just with different colors.
I already set up one of the with all the collisions, navigation, bitmap and Z index I needed.
I duplicated the tileset and wanted to know how can I change the texture I used for it without having to reset all the collision and other stuff.
Help

Edit: I found a solution.
I went into the files on my file explorer, opened the tileset map with a text editor, changed the external resource path to the texture I wanted and it worked.
I’m gonna leave this post if someone was having the same problem and couldn’t find help.

:bust_in_silhouette: Reply From: Idleman

I was having the same need to change the texture only for a TileSet. The way I do it is that first use tile_set.get_tiles_ids ( )or just get the IDs from the TileSet window to get the ids for the tile you want to change image, then use tile_set_texture ( id, newTexture )to change the current texture to a new texture. Remember to load the image as newTexture first, simple sample code below is to change tile ID 0 to a new texture.

var newTexture = load("res://Image/NewTexture.png")
$Tilemap.tile_set.tile_set_texture(0, newTexture)