How to change texture of sprite in GDScript

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

Hello everyone!
I want change texture of my TextureButton in GDScript.
How do this?

:bust_in_silhouette: Reply From: jgodfrey

If I understand what you’re asking, you just need to assign a new texture to the texture_focused property of your TextureButton. So, something like this:

extends Control

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

func _ready():
	$TextureButton.texture_focused = texture