Godot Version
4.5.0
Question
I have created two theme type variations for a Label: “SmallLabel”, and “MediumLabel”.
I have a scene called “CostLabel” which has a “Label” child node. In a script attached to “CostLabel” I have a function called “set_label_size”:
Scene Structure:
| - CostLabel: HBoxContainer
- | - - Label: Label
func set_label_size(label_size: String) → void:
if not SIZES.has(label_size):
print(“CostLabel size not valid”)
else:
# type variant here is either "SmallLabel" or "MediumLabel"
$Label.set_theme_type_variation(SIZES.get(label_size).get(“type_variant”))
The idea is, when I instantiate a CostLabel, I want to be able to set a particular font size via type variation.
The problem is that the type variation gets applied to ALL instantiated CostLabel scenes. Meaning, if the last CostLabel instantiated has set_label_size called with argument “medium”, all CostLabel font sizes will be the MediumLabel size, the same is true for the “small” argument.
I’m new to Godot, so please forgive me if this is a misunderstanding on instantiated scenes. If there is a better way to achieve my goal, please let me know!
Thank you