+1 vote

Is there a way to add text to a texture button node like the regular button node? and how can I scale a texture button node to the same scale as the vBoxContainer node?

in Engine by (27 points)

3 Answers

+3 votes

Well, TextureButtons use images instead of text, hence the name ^^
But of course you can always add a label on top of it.

by (922 points)
I figured that would be the only way. . . maybe later it can become more like the default button node. . .
+1 vote

If you will be using a lot of that kind of buttons it might be good idea to create custom skin You can just change texture and font of button, no need to skin all gui controls

by (368 points)
0 votes

To scale the button, you can try:

extends TextureButton

func _ready(): set_texture_scale(Vector2(get_rect().size.x/get_minimum_size().x, get_rect().size.y/get_minimum_size().y))

As long as the texture button is set to fill so the rect will stretch as far as the vbox.

Well that code works for me anyways...
I made an issue about this a while back, you're welcome to chip-in.

by (16 points)
Indeed there seems to be a minor bug (or feature) that prevents  distorting the texture via manually resizing the TextureButton.
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 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 webmaster@godotengine.org with your username.