+4 votes

Can I change the custom_constants of a node via script during run time or at least on loading?

in Engine by (18 points)

2 Answers

+5 votes

This may be an old question, but it's worth answering for anyone else looking this up: in order to change a theme constant you must call add_constant_override("<constant name>", <value>).

Documentation source: https://docs.godotengine.org/en/3.2/classes/class_control.html#class-control-method-add-constant-override

by (66 points)

You saved my life! Thank you.

0 votes

In Godot 4, you should go like this for theme constant overrides:

add_theme_constant_override(name :String, constant :int)

For instance:

add_theme_constant_override("separation", 10)
by (58 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 [email protected] with your username.