How to change texture of TextureButton in GDScript?

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

I need change texture of my TextureButton.
I asked this question earlier, but i described it wrong.
I don’t need to change his states, only current texture.
So, how to do this?

:bust_in_silhouette: Reply From: jgodfrey

So, that’d be nearly identical to the answer I provided in your previous question, except you’d want to set the texture_normal property. So, this (for example):

var texture = preload("res://icon.svg")

func _ready():
	$TextureButton.texture_normal = texture

Note, the above script is assumed to be attached to the parent node of the TextureButton. If the script is on the TextureButton itself, you’ll need to remove the $TextureButton. part of the code…

jgodfrey | 2023-04-13 13:39

Ok, thank you!

TheVorkMan_ | 2023-04-13 16:29