Using LabelSettings in GDScript

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

I’m new to Godot so this may seem a very silly question but how do I attach LabelSettings to a label via GDScript? I have several labels created within a loop in gdscript and I want to change their color & font. I have the following code but don’t know how to link the 2 so that the settings affect the label.
var disp = var ls = ls.set_font_color("Red") disp.text = str(loop_counter)


:bust_in_silhouette: Reply From: jgodfrey

Assuming you have a valid LabelSettings object and references to one or more Label controls, you can simply assign one to the other. So, something like:

# Create a LabelSettings object and set its properties
var ls = 

# Assign the LabelSettings object to any number of labels
$Label1.label_settings = ls
$Label2.label_settings = ls

That simple, geez I feel stupid; I tried pretty well everything except the obvious. Thankyou so much.

whitelegs | 2023-04-15 19:30