Godot Version
v4.3.stable.mono.official [77dcf97d8]
Question
I made scene with 2 colorRects and 1 label. The color rects represent the “background” and “corners”, and I want to size them according to the text, so that they are just big enough to fit it. Here is the script I’m using currently:
public override void _Ready()
{
description = GetNode<Label>("Description");
corner = GetNode<ColorRect>("Corner");
bg = GetNode<ColorRect>("Background");
SetText("gwsjklnsrjkgsrgk\nwnherjogrjgb");
}
public void SetText(string s)
{
description.Text = s;
bg.Size = description.Size;
corner.Size = new Vector2(bg.Size.X + cornerWidth*2, bg.Size.Y + cornerWidth*2);
}
I tought that setting the text would automatically resize the label, but apparently not, since once I run the scene the bg and corner remain the same size. How can I do this?