Godot Themes
Godot Themes are a very powerful way to skin your GUI. If you only have a couple of GUI elements, then creating a theme is probably overkill. But as soon as you have more GUI elements, I would always recommend working with themes. So, how does this work? We will have a look at what themes basically are, what you can do with them, and how you can create them.
About the Godot Theme
If you already created a GUI element, for example, a button, in the past, then you probably know, that you can give that button a unique look. You can give the button custom colors, a custom font, etc. so that it fits the style of your game. But if you make a new button, you have to assign all those custom things to that button again. Now imagine you have hundreds of buttons.
This is where Godot Themes come in very handy. Because you can create a theme, in this theme you can define how a button should look, and then apply that theme to as many buttons as you like. Voila, now that button will look as you defined in the theme. And the best thing: if you later decide, that you want your button to look different, just change the theme and that is it. Also, of course, themes don’t just work with buttons, but with just about every GUI element in Godot. Sounds like a useful thing to have, right?
How to create a theme
Let’s have a look at how to create such a theme. First, create any GUI element, for example, a button. In the Inspector you will find Theme and there you can create a New Theme (Check out the screenshot).
As with any resource in Godot, you can then save this theme, to use it for other GUI elements.
Next, we have to add the item, in our case the button. So you want to go to Edit theme… and click Add Class Items.
Chose the Button from the drop-down list and click Add All. On the right-hand side in the Inspector you now will find Colors, Constants, Fonts, and Styles. You can customize them just as you like. Don’t forget to save the theme, when you are done. Every GUI element, that you add will show up in the Inspector and will be customizable. Now you can add this newly created theme to every button and the button will change its look accordingly. If you change the theme, all buttons will change too.
Godot Themes are great!
If you are working on bigger projects, I would always recommend using themes for your GUI elements. Once the theme is set up, it makes it easy to change the look of your GUI without a lot of extra work. Also, themes make sure, that your game has a consistent style. Fun fact: even the GUI of Godot itself uses the theme framework.
You can have a look at the official documentation for some more information on the topic. Also, this site can be useful, if you want to read more about themes.
If you did find this post informative, let me know in the comments section below. I would love to hear from you. Also, feel free to check out other posts about the Godot Engine on this section of my website.
Originally published at www.gotut.net.