Search code examples
godotgodot4

VBoxContainer not separating PackedScene Control Node children


I have a packed scene whose layout is like so:

Control
- Label
- Label
- MenuButton
- RichTextLabel
- SubViewportContainer
- - SubViewport
- - - MeshInstance3D
- - - MeshInstance3D
- - - Camera3D

I instantiate instances of the scene, fill out the necessary details (text for labels, mesh for mesh instances, etc), then add them as children to a VBoxContainer who is the child of a ScrollContainer, but they are only offset by a few pixels, not the 100 pixels the Control node's size.y is set to. I tested it by manually adding instances of the Packed Scene and the same issue occurs. Why is this? How do I fix it?


Solution

  • You have to set the Control Node's custom minimum size, even if you're using scene instances. Since I'm instantiating them with code in this case, this could be fixed using set_custom_minimum_size(Vector2(0, 100)), although since they're all meant to be the same size it makes more sense to set the minimum size within the Inspector in the Scene view itself.