[4.6.2] Double checking before I do something silly to apply a texture to a button

Godot Version

4.6.2, 2D

Question

So!
I need to apply a texture to a script created button. I cannot find a direct override beyond a stylebox override. So I apply the stylebox override. But the stylebox cannot take textures directly, so I draw it from a canvas item. But I can’t just make a canvas item. So I create an RID to call the canvas item with. But now I need to also find the command to call the RID with.

At this point, I started to wonder if this was all just unbelievable silly and I was missing something obvious, but because of other commands I was calling required a normal button and not a TextureButton, I decided to put my conundrum here.

If this is doomed to begin with, is there at least a way to make the button transparent so I can slot the texturebutton under the actual button? It would have to be by GDScript, of course, since the button was also created with GDScript, but that would at least feel a little less silly and complex than this nonsense.

you can replace the button’s StyleBox with a StyleBoxTexture and make the necessary changes to it, since it works like a NinePatchRect.

Yup, that did the trick. It ended up looking like this:

ActiveStyles.append(StyleBoxTexture.new())
ActiveStyles[si].set_texture(load(Local[11]))
ActiveInstances[i].add_theme_stylebox_override("normal", ActiveStyles[si])
si += 1

…and I presume the field that ‘normal’ is in refers to the state. Thank you comrade!