A plugin for Godot that allows for more complex and visually attractive panel designs without creating textures.
There were several occasions where I wanted to create panel designs that sounded quite trivial, like a gradient with rounded corners, but it was impossible to do with either StyleBoxFlat or StyleBoxTexture. I found myself having to look for alternatives, such as creating a specific texture, using shaders, creating nodes with clip children, or manually drawing my nodes. Each of these options had its drawbacks, so I created my own StyleBox seeking to expand StyleBoxFlat functionality to make it a much more flexible tool.
Main features:
- Rounded panels with texture
- Border textures
- Stackable borders
- Corner shapes
This plugin seeks to fill the gap between Godot's StyleBoxFlat and StyleBoxTexture.
The minimum Godot version required is 4.4
Add a new StyleBoxFancy to a panel or button.
StyleBoxFancy comes with similar properties as StyleBoxFlat such as:
ColorSkewCorner radius/Corner detailExpand marginsShadowAntialiasing
Warning
Setting a StyleBoxFancy or any other custom resource in the main theme of a project might yield Parameter "SceneTree::get_singleton()" is null error, this is a bug from godot,
see this github issue
Allows you to apply a Texture2D to your panel, it is compatible with rounded corners and antialiasing. A common use for this is creating a rounded panel with a GradientTexture2D which is not possible using Godot's StyleBoxes.
If a texture is set its color will be modulated by the color property, so if you don't want to modify the texture's color then set color to white.
Allows you to change the corner shape based on a superellipse formula, mirroring the upcoming css feature.
Different curvature values give different corner shapes:
- 1: Round
- 2: Squircle
- 0: Bevel
- -1: Scoop
- -2: Reverse Squircle
Positive values make convex corners that get closer to a square and negative values give concave corners.
Shadow has a dedicated enabled property that allows using shadows with 0 blur.
The spread property will expand or shrink the shadow compared to its original panel size.
StyleBoxFancy implements borders as a list of StyleBorder so you can have more than 1 border, each StyleBorder has its own properties and are drawn stacked one on top of another. It includes the same properties as StyleBoxFlat's border.
Allows you to apply a Texture2D to your border.
If a texture is set its color will be modulated by the color property, so if you don't want to modify the texture's color then set color to white.
By default borders will stack so each border is moved inwards, by enabling this property it will be drawn as it were the top border regardless of its position on the list, and it will not interact with other borders.
Allows you to move each side of the border inwards leaving an empty area behind, it can also be moved outwards with a negative value.
Compared to StyleBoxFlat it is about 10~ times slower, mainly due to it being written in GDScript and not C++
This is not a problem for a majority of use cases, only games with lots of UI or constant animations may have to consider this.
Note
Tested with 1000 panels constantly being redrawn each frame with both StyleBoxes having a border and antialiasing on, using Godot's profiler measuring Frame Time (ms).
- StyleBoxFlat: 34.24 ms
- StyleBoxFancy: 334.10 ms
- In your godot project open the AssetLib tab and search for "Fancy StyleBoxes".
- Download and install into your addons folder.
- Enable the plugin in
Project/Project Settings/Plugins.
- Download the latest release here.
- Inside the zip file should be an "addons" folder, uncompress it and move it to your project root folder.
- Enable the plugin in
Project/Project Settings/Plugins.