I have a saved scene made out a of PanelContainer and some controls. When I add it to the main scene with AddChild() it looks correct, but for some reason after I change the position (even if it's just node.Position = node.Position) it stretches to over 1000 pixels vertically, even though it should only be around 300. When I manually set the size to 0 in the Remote tab, it looks correct again, though when I tried doing the same from code after changing the position (node.Size = Vector2.Zero;) it didn't help.
I know the culprit is a RichTextBox inside the PanelContainer, it has "Fit Content" enabled, and when I disable it the problem again goes away. The structure is:
- PanelContainer (root)
- VBoxContainer
- RichTextLabel
For testing I hid all the other nodes.
In the remote inspector the RichTextBox's size shows up correctly: (34, 362), but when I log it right after adding it to the scene and after changing the position it's (1, 986) in both cases. I'm changing the RichTextLabel's content from code, but I know that's not causing the issue, it still happens when even I completely remove the script that does that.
So... 1) the RichTextBox's size is wrong after being instantiated, 2) the parent container only stretches to fit this wrong size after its position is updated, and 3) by the time everything is loaded and I look in the remote inspector, the RichTextBox's size is correct, the VBoxContainer's size is correct, but the PanelContainer is still stretched to the wrong size. Does anyone know what to do with this?
Edit: I don't remember the order in which nodes load but just in case I checked that the RichTextLabel is ready by the time I log its size, label.IsNodeReady() and label.IsFinished() both return true. label.CustomMinimumSize correctly returns (0,0).