I’m making use of an OptionButton in my game, which I am styling by changing the themes on a PopupMenu.
As seen in the image below, I have rounded the corners of the PopupMenu panels, however, there are still some remnants of a grey background (see where arrows are pointing).
I hope to remove this grey background and have tried to do so by changing the themes on many different nodes, to no avail.
If anyone knows the solution to this, it would be greatly appreciated, thanks
i think there’s an option to turn it round by making the window as transparent
the grey area is a window background, so you need to switch the transparent background option on to make it look round
I’ve found a property transparent_bg under the PopupMenu’s Viewport node properties
It does what I’m looking for, however I can’t seem to access it as it’s created dynamically whenever the button is set up (I presume)
seen below is the remote scene tree during a play test
I’ve tried to get a reference to the PopupMenu node that is created but it doesn’t seem to want to let me, see below
func setBackgroundTransparent():
# Check that the popup menu has children
var children = button.get_children()
print(children)
print(children.size())
if children.size() == 0:
await get_tree().create_timer(0.25).timeout
await setBackgroundTransparent()
var popupWindowNode = children[0]
if not popupWindowNode is PopupMenu:
await get_tree().create_timer(0.25).timeout
await setBackgroundTransparent()
popupWindowNode.set("transparent_bg", true)
The two print statements in this code just continually print an empty array and a size of 0, so I’m not sure what’s going on
In the actual editor the only thing that is there is the OptionButton node
The PopupMenu is created by the engine whenever I run the game, so I can’t change its properties from the editor because it’s not there, hence why I’m trying to get a reference to it through code
the function I sent earlier (setBackgroundTransparency()) is being called recursively every .25 seconds so it should wait until there is a child to perform the setting of the transparent background,
even after letting it run for a few minutes the OptionButton apparently still has no children, when in the remote scene tree it looks like it should
@onready var button: OptionButton = $Control/MarginContainer/OptionButton
I can assure you the reference is valid
Did you add the PopupMenu node to the scene tree yourself? the one I’m trying to reference only exists on the remote tree – i.e. while the game is running
I’ve figured it out - had to pass the include_internal parameter through the get_children() call for it to recognize the PopupMenu inside the OptionButton
var children = button.get_children(true)
thanks for taking the time to offer your help though, I truly appreciate it, thanks
I didn’t change anything about the scene tree - no new children added or anything
The PopupMenu is created by the engine as an internal child of the OptionButton (I think… whatever that means), so I just had to tell my code to look for those internal children when trying to get the children of the OptionButton