The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

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...

in Engine by (824 points)

2 Answers

+2 votes
Best answer

... 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.

by (824 points)

i was about to answer the load solution :-)

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

0 votes

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

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.