Class reference
EditorDock
Inherits MarginContainer
Dockable container for the editor.
Description
EditorDock is a Container node that can be docked in one of the editor's dock slots. Docks are added by plugins to provide space for controls related to an EditorPlugin. The editor comes with a few built-in docks, such as the Scene dock, FileSystem dock, etc. You can add a dock by using EditorPlugin.add_dock(). The dock can be customized by changing its properties.
@tool
extends EditorPlugin
# Dock reference.
var dock
# Plugin initialization.
func _enter_tree():
dock = EditorDock.new()
dock.title = "My Dock"
dock.dock_icon = preload("./dock_icon.png")
dock.default_slot = EditorPlugin.DOCK_SLOT_RIGHT_UL
var dock_content = preload("./dock_content.tscn").instantiate()
dock.add_child(dock_content)
add_dock(dock)
# Plugin clean-up.
func _exit_tree():
remove_dock(dock)
dock.queue_free()
dock = null
Properties
int available_layouts = 1
The available layouts for this dock, as a bitmask. If you want to make all layouts available, use available_layouts = DOCK_LAYOUT_VERTICAL | DOCK_LAYOUT_HORIZONTAL.
bool clip_contents = true
int default_slot = -1
The default dock slot used when adding the dock with EditorPlugin.add_dock(). After the dock is added, it can be moved to a different slot and the editor will automatically remember its position between sessions. If you remove and re-add the dock, it will be reset to default.
Texture2D dock_icon
The icon for the dock, as a texture. If specified, it will override icon_name.
Shortcut dock_shortcut
The shortcut used to open the dock. This property can only be set before this dock is added via EditorPlugin.add_dock().
StringName icon_name = &""
The icon for the dock, as a name from the EditorIcons theme type in the editor theme. You can find the list of available icons here.
String layout_key = ""
The key representing this dock in the editor's layout file. If empty, the dock's displayed name will be used instead.
String title = ""
The title of the dock's tab. If empty, the dock's Node.name will be used. If the name is auto-generated (contains @), the first child's name will be used instead.
Methods
void _load_layout_from_config(ConfigFile config, String section) virtual
Implement this method to handle loading this dock's layout. It's equivalent to EditorPlugin._set_window_layout(). section is a unique section based on layout_key.
void _save_layout_to_config(ConfigFile config, String section) virtual const
Implement this method to handle saving this dock's layout. It's equivalent to EditorPlugin._get_window_layout(). section is a unique section based on layout_key.
void _update_layout(int layout) virtual
Implement this method to handle the layout switching for this dock. layout is one of the DockLayout constants.
_update_layout(layout):
box_container.vertical = (layout == DOCK_LAYOUT_VERTICAL)
Constants
DOCK_LAYOUT_VERTICAL = 1
Allows placing the dock in the vertical dock slots on either side of the editor. Note: Currently this flag has no effect because the bottom panel is not a proper dock slot. This means that the dock can always be vertical.
DOCK_LAYOUT_HORIZONTAL = 2
Allows placing the dock in the editor's bottom panel. Implement _update_layout() to handle changing layouts.