Add Theme Constant Override for Separation Not Working

Godot Version

4.2.1

Question

I’m trying to adjust the ‘separation’ theme override constants on VSeparators using code, and from what I’ve found online the solution is supposed to be .add_theme_constant_override(“separation”, value), but I haven’t been able to get it to work. Here’s the code I have going:

if p1_row == "Front":
	p1_row = "Back"
	p1_back_row.add_theme_constant_override("separation", 0)
	p1_front_row.add_theme_constant_override("separation", 30)
elif p1_row == "Back":
	p1_row = "Front"
	p1_back_row.add_theme_constant_override("separation", 30)
	p1_front_row.add_theme_constant_override("separation", 0)

Not sure what I’m missing - any help is appreciated!

Please share the structure of your scene.

Sure thing; there’s a bunch of other stuff in there but this is the path to the nodes in question (represented by p1_back_row and p1_front_row).

I know the code is getting to the if statements because I used a little print(“test”) inside of them. Just not sure what to add after p1_back_row and p1_front_row to adjust their separation constant. Also the code is from the pause_menu script if that helps.

EDIT: It is working now! I’m actually not sure what I did, so it may have just been closing and reopening Godot. But at least now I know that .add_theme_constant_override() is working on my system!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.