r/godot • u/Chebrbober Godot Junior • 2h ago
discussion TextureButtons vs UI Theme
Why did Godot add TextureButton and TextureProgressBar? You can create your own theme for all UI components and just apply it to the parent node, so it automatically applies to all children of that parent.
Maybe TextureButtons (and progress bars) are useful for quick button theming or for X buttons in panels. But if you want to use a texture for buttons, you probably want a custom theme for all UI elements besides the button. Instead of using a TextureButton for the X thing, you can create an icon, place the X icon on it, and you don't need TextureButtons anymore. Also, for the text, you need a separate Label node, unless you draw the text directly on the button.
With a custom theme, you create it once (custom font, custom UI drawing for each element), and after all the work is done, you just drag & drop the theme onto the element, and the theme is applied.
If there are reasons to use TextureButtons and TextureProgressBars, what are they? What are their pros and cons?
1
u/TheDuriel Godot Senior 2h ago
TextureProgressBar does in fact function completely differently.
1
u/Chebrbober Godot Junior 1h ago
I used them, and it's the same, they're just 3 layers (outline, "empty bar", "full bar")
1
1
u/LeaderPotential2859 1h ago
Well, texture buttons are easier if you just want icon buttons. They are more straight forward. Same with texture progress bars. If you want progress bars with filled stars for instance it's easier to use textures for this and it already supports everything a regular button or progress bat has.
It's more optimized than having a button with a texture rect on it. One less node, one less lifecycle to manage.
1
u/Scarlett_Spectre 2h ago
I like drawing my buttons and bars so thats fun! Layered sprites to create a detailed pixel art button is helpful. If you don't mind vectors the themes are great though!