Can't seem to set_texture on a TextureFrame

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Robster
:warning: Old Version Published before Godot 3 was released.

Hi all,

I have a TextureFrame called TypeL.

On the click of another button I want to change the image on this TextureFrame.

Here is my code:


When I run and click the button, this is the error:
Invalid type in function 'set_texture' in base 'TextureFrame'. Cannot convert argument 1 from String to Object.

I’ve had a look around. The docs basically just have this:
void set_texture ( Object texture )

I don’t know what I’m doing wrong. Any advice would be really appreciated. Thanks so much…

:bust_in_silhouette: Reply From: Robster

… annnnnd I answered it myself. There’s something about typing it out that helps sometimes.

Well, for others in the future I had to make the texture/png an object. Here’s how I did it:

	#load the CPU image
	image = load("res://textures/cpu.png")
	#change the visuals

Once the png file was an object I could then use that object to change the texture! Learning all the time. Hope that helps someone.

i was about to answer the load solution :slight_smile:

mokalux | 2017-02-04 01:55

good answer, or you can just use …(which worked better for my application)


GodotBadger | 2020-05-30 00:21

:bust_in_silhouette: Reply From: lastrodamo

Few month ago i search a solution for this error
On top of my script I declare this :

onready var material_body = preload("res://assets/drone/Peinture.material")
onready var graph2 = preload("res://assets/drone/images/graph2.png")

and in my button function :

func _on_button_graph2():
	material_body.set("albedo_texture", graph2)

You can test a solution of my project in this link

In my case get_texture() and set_texture() not work