Godot Version
4.2.1
Question
I try to programmatically add a GridContainer to a Node2D:
public override void _EnterTree(){
var grid = new GridContainer()
{
Position = new Vector2(GetViewportRect().Size.X/2, GetViewportRect().Size.Y/2),
Columns = 2,
};
for( var i = 0; i < 20; ++i)
{
var container = new Control(){
Size = new Vector2(100, 100)
};
container.AddChild(new ColorRect(){
Size = new Vector2(100, 100),
Color = new Color(i/20f, i/20f, 1)
});
grid.AddChild(container);
}
}
AddChild(grid);
The result looks like GridControl thinks the first elements are only 1x1 in size: