Is it possible to change custom constants via script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Afsar Pasha

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

:bust_in_silhouette: Reply From: Capital-EX

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: Control — Godot Engine (3.2) documentation in English

You saved my life! Thank you.

isdran | 2022-03-29 17:28

:bust_in_silhouette: Reply From: kuzey

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)
1 Like