How Can I change bg_color of stylebox of button node by coding?(C#)

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

I set the button’s color by themeoverrides.
And, I tried to change bg color of button by coding;
Set("custom_styles/normal/bg_color", Color.Color8(255,0,0,255));
However, runnning that code, the bg color of button returns to initial one.
Please tell me how can I change bg color

:bust_in_silhouette: Reply From: zbyna

Button inherits from Control node. When I wanted to change font in RichTextLabel (originates from Control node too) I used:

var fontForExplanation = rtlExample.GetFont("normal_font","");
(fontForExplanation as DynamicFont).Size = 24; 

There may be hints here:

Theme resources change the Control’s appearance. If you change the Theme on a Control node, it affects all of its children. To override some of the theme’s parameters, call one of the add_override methods, like AddFontOverride(String, Font). You can override the theme with the inspector.
Note: Theme items are not Object properties. This means you can’t access their values using Get(String) and Set(String, Object). Instead, use GetColor(String, String), GetConstant(String, String), GetFont(String, String), GetIcon(String, String), GetStylebox(String, String), and the add
_override methods provided by this class.

And here (there are examples in this address, which may help)

GetColor(String, String)
Returns a Color from the first matching Theme in the tree if that Theme has a color item with the specified name and theme_type. If theme_type is omitted the class name of the current control is used as the type. If the type is a class name its parent classes are also checked, in order of inheritance.
For the current control its local overrides are considered first (see AddColorOverride(String, Color)), then its assigned Theme. After the current control, each parent control and its assigned Theme are considered; controls without a Theme assigned are skipped. If no matching Theme is found in the tree, a custom project Theme (see ) and the default Theme are used.