GridContainer separation values in code

Godot Version

4.3.stable.mono

Question

Can I adjust the separation properties of a GridContainer via code?

Case:
A 2d project with a GridContainer that is a child of the main node of the scene.

I’m trying to adjust the grid, based on some data I load from a file on start.

I can set the columns of the grid by giving value to the ‘columns’ property.

grid_container.columns = columns_count

What I can’t find how to do is if I can adjust the separation properties.
I tried:

grid_container.set("h_separation", some_grid_h_separation_value)

I saw an advise about using set_constant_override() instead of set(), but there’s not such method for GridContainer (may be there was in Godot < 4).

Any help would be appreciated!

Hi,
It’s called add_theme_constant_override("h_separation", 5) and it’s a method of Control.

1 Like

Hi.

That’s it. I don’t know how I missed that! Don’t tackle problems late at night, I guess :slight_smile:

Thanks!