Material Box

Material Box

WEB Design & Material Images

Godot - Making Label Text Semi-Transparent

Godot

This is a code example for making the text of a Label node semi-transparent in GDScript.


You can set the `font_color` property with `add_theme_color_override()`, and specify the transparency in the last argument, in the range from `0` to `1`.
However, this method requires you to specify the text color again.

var label = Label.new()
add_child(label)

# Make Label text semi-transparent
label.add_theme_color_override("font_color", Color("#FFF", 0.5))

You can change the alpha value of the Label node by specifying the `a` property of the `modulate` property.
This method affects the entire Label node, so if you have specified a background color or border, you may not get the expected results.

# Make Label node semi-transparent
modulate.a = 0.5

Godot

TitleGodot - Making Label Text Semi-Transparent

CategoryGodot

Created

Update

AuthorYousuke.U