• Godot HelpGUI
  • What are the differences between using TextureButton and a Button with a custom StyleBoxTexture?

I'm new to Godot, just finished the menu and GUI tutorials. I came over from using UnrealI and libgdx before. I'm really enjoying Godot.

As I was trying to apply what I'd learned in the tutorials, I came across an issue. I think I'm missing some fundamental understanding in the limitations/uses of TextureButtons. I found this post with a comment from Calinou which answered part of what I was looking for. But reading his comment made stop and wonder what I was missing about TextureButtons and the parent Containers.

I would like to save myself some headaches if I can, and was hoping someone would explain if/when to use TextureButtons and when to use Buttons with a custom StyleBoxTexture. It seemed intuitive to use a nine-patch texture with a TextureButton. As well, what are the pitfalls of using containers with elements that will change shape? Can I 'reserve' a shape-space in a container cell and tween the children inside the limits of the space?

Description of what I'm trying to do: I'm trying to design a menu layout and have control over how the elements are positioned on separate devices and orientations. I'm also trying to animate several properties of individual menu elements without effecting the overall menu's layout. My approach was to create a layer-stack of textures for animated elements so I could could change the size/color/alpha in response to UI actions/events(a stack of textures to be used as one menu button texture). I've made complex menus in Unreal before, it was a pain animating UI components. I don't expect Godot to have a magic wand to fix my problem. I just want understand the different concepts in Godot so I can use them appropriately to approach my problem.

My approach was to create a layer-stack of textures for animated elements so I could could change the size/color/alpha in response to UI actions/events(a stack of nine-patch png textures with thin stylized button outlines to be used as one menu button texture). My thought was to use a stack of nine-patch textures for the textures of the buttons. Then I would use constraints to the parent containers to maintain the menu layout, and use tweens in order to 'animate' the texture menu items.

Thanks for any help clarifying this.

Not sure, but I'd be interested to know if there is a benefit one way or the other.

Also, welcome to the forums!

9 days later

1st, if you have used a ninepatch before, a normal button theme acts the same as a ninepatch except gives extra controls expanding, etc. Themes do require you to have a button down nine patch, an non pressed patch, and so on.

A texture button doesn't have those features but used for custom arrow textures, icon buttons, or similar things that dont need to be stretched through nine patch.

Btw dont make your own buttons from scratch but use themes/texture buttons, it'll save you hours of deving.

Thanks, I started using themes and was modulating them in the various pressed/hovered states. I'm probably going to use separate textures, like you said. I've given up on trying to add animations for button presses for now. I was hoping to animate a tweened size change to the button or the button's shadow. But... after nearly throwing my laptop out the window trying to figure out containers and controlling their size/position, I decided to work on something other than the GUI for a while.

@cybereality said: Not sure, but I'd be interested to know if there is a benefit one way or the other.

Also, welcome to the forums!

Thanks for the welcome @cybereality

3 years later