I’m working on a plugin that primarily exposes its interface using a spatial editor menu. It’s a minor thing, but I’ve noticed that my menu ends up sharing a background with the menu from a different addon.
In this image, that “Terrain” menu on the right comes from the godot_voxel add-on. I add a single scene with an HBoxContainer root that holds two icons at the very end. The separator appears to be system-provided, as I’m not adding it (intentionally) and it is removed if I disable my own plugin.
My expectation would be that each menu would have its own, disconnected backgrounds and not include the separator. Right now, they kind of appear to be part of the same system, and while definitely related, they are distinct.
Control nodes added to the EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU are added to a HBoxContainer which is a child of a PanelContainer:
The PanelContainer is the one adding the background.
A VSeparator is added automatically for each Control node added into the same menu:
You could add it manually like:
@tool
extends EditorPlugin
var other: Button
var my_control: Label
func _enter_tree() -> void:
other = Button.new()
other.text = "Other Plugin"
add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, other)
my_control = Label.new()
my_control.text = "I'm out"
# Find the HFlowContainer of the Node3DEditor
var root = EditorInterface.get_base_control()
var candidates = root.find_children("*", "Node3DEditor", true, false)
if candidates.size() > 0:
var editor_3d = candidates[0]
candidates = editor_3d.find_children("*", "HFlowContainer", true, false)
if candidates.size() > 0:
# There may be multiple HFlowContainers in the Node3DEditor.
# This assumes the first one is the one we want.
var flow_container = candidates[0]
flow_container.add_child(my_control)
func _exit_tree() -> void:
if is_instance_valid(other):
remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_MENU, other)
other.queue_free()
if is_instance_valid(my_control):
my_control.queue_free()