How to add a style (.tres) in Label

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MIE1981

Hi,

I am new here, and in Godot, and also in Game development. I try to create a label using GDScript and apply a custom_styles/normal on it. I can’t find any documentation or post anywhere that explain it.

I already created the “.tres” style.

Any Idea?

	var label: Label = Label.new()
	label.set_text("Example")
	label.set("custom_styles/normal", "res://path_to_tres/example.tres")

Thanks,

:bust_in_silhouette: Reply From: exuin

You also need to load the resource by calling the load() function and passing that path as a parameter.

Hi,
It works!
Thanks,

MIE1981 | 2021-09-10 06:36