+1 vote

I am trying to set a Theme property of a Grid Container through code, specifically, custom_constants > hseparation.

I know how to set the property index of a Grid Container (For example, $GridContainer.columns =3) through code.
But I don't know to set the Theme Properties as given in the documentation:

Theme Properties
int vseparation [default: 4] The vertical separation of children nodes.
int hseparation [default: 4] The horizontal separation of children nodes.

I want to change the default from 4 to some other value, say 5.

Thanks for your help.

in Engine by (100 points)

2 Answers

+1 vote
Best answer

Yeah, the documentation isn't clear at all regarding those two.

In any case, h/vseparation are constants. You can access them from the GridContainer node with $GridContainer.get_constant("hseparation"). If you need to change the value, you'll have to call $GridContainer.add_constant_override("hseparation",8).

by (292 points)
selected by

This works.
Thanks a lot.

How to set the size of a TextureRect through code?
0 votes

Well done with this article!

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.