Topic was automatically imported from the old Question2Answer platform.
Asked By
Farflame
I’m trying to change the texture of my TextureRect when I click it. I was hoping that I could set all the frames in the animation, set it to 0 fps and just change to whichever frame I wanted, but I don’t see an option to do that. Alternatively, is there a way that I could just set the texture in code, e.g something like …
MyImage.Texture = "res://Graphics/image.png"
That doesn’t work but I’m trying to find some way to change the texture in code.
Texture is a Texture property, you can’t assign text to it like you wrote.
You should load the texture from the path instead, because then load will return the proper texture: MyImage.texture = load("res://Graphics/image.png")
Not working for me, I’m getting an error - Invalid set index ‘Texture’ (on base: ‘TextureRect (Kit.gd)’) with value of type ‘StreamTexture’.
Farflame | 2019-07-02 00:52
Sorry, it’s lowercase texture.
Zylann | 2019-07-02 00:55
Oh yeah, lol, it was that simple. Thanks, I’ve accepted this as the best answer.