EditorDock
实验性: This class may be changed or removed in future versions.
继承: MarginContainer < Container < Control < CanvasItem < Node < Object
派生: FileSystemDock
Dockable container for the editor.
描述
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 = EditorDock.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
教程
属性
BitField[DockLayout] |
|
|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
方法
void |
_load_layout_from_config(config: ConfigFile, section: String) virtual |
void |
_save_layout_to_config(config: ConfigFile, section: String) virtual const |
void |
_update_layout(layout: int) virtual |
void |
close() |
void |
|
void |
open() |
信号
closed() 🔗
Emitted when the dock is closed with the Close button in the context popup, before it's removed from its parent. See closable.
枚举
flags DockLayout: 🔗
DockLayout DOCK_LAYOUT_VERTICAL = 1
Allows placing the dock in the vertical dock slots on either side of the editor.
DockLayout DOCK_LAYOUT_HORIZONTAL = 2
Allows placing the dock in the editor's bottom panel.
DockLayout DOCK_LAYOUT_FLOATING = 4
Allows making the dock floating (opened as a separate window).
DockLayout DOCK_LAYOUT_ALL = 7
Allows placing the dock in all available slots.
enum DockSlot: 🔗
DockSlot DOCK_SLOT_NONE = -1
The dock is closed.
DockSlot DOCK_SLOT_LEFT_UL = 0
左侧停靠槽的左上(默认布局中为空)。
DockSlot DOCK_SLOT_LEFT_BL = 1
左侧停靠槽的左下(默认布局中为空)。
DockSlot DOCK_SLOT_LEFT_UR = 2
左侧停靠槽的右上(默认布局中为“场景”和“导入”面板)。
DockSlot DOCK_SLOT_LEFT_BR = 3
Dock slot, left side, bottom-right (in default layout includes FileSystem and History docks).
DockSlot DOCK_SLOT_RIGHT_UL = 4
Dock slot, right side, upper-left (in default layout includes Inspector, Signal, and Group docks).
DockSlot DOCK_SLOT_RIGHT_BL = 5
右侧停靠槽的左下(默认布局中为空)。
DockSlot DOCK_SLOT_RIGHT_UR = 6
右侧停靠槽的右上(默认布局中为空)。
DockSlot DOCK_SLOT_RIGHT_BR = 7
右侧停靠槽的右下(默认布局中为空)。
DockSlot DOCK_SLOT_BOTTOM = 8
Bottom panel.
DockSlot DOCK_SLOT_MAX = 9
代表 DockSlot 枚举的大小。
属性说明
BitField[DockLayout] available_layouts = 5 🔗
void set_available_layouts(value: BitField[DockLayout])
BitField[DockLayout] get_available_layouts()
The available layouts for this dock, as a bitmask. By default, the dock allows vertical and floating layouts.
If true, the dock can be closed with the Close button in the context popup. Docks with global enabled are always closable.
该属性定义了使用 EditorPlugin.add_dock() 方法添加此面板时,所使用的默认停靠槽位。
面板添加后,可被移动至其他槽位,编辑器会自动在不同会话间记住其位置。若移除后重新添加,该面板将被重置至默认槽位。
The icon for the dock, as a texture. If specified, it will override icon_name.
The shortcut used to open the dock.
bool force_show_icon = false 🔗
If true, the dock will always display an icon, regardless of EditorSettings.interface/editor/dock_tab_style or EditorSettings.interface/editor/bottom_dock_tab_style.
If true, the dock appears in the Editor > Editor Docks menu and can be closed. Non-global docks can still be closed using close() or when closable is true.
StringName icon_name = &"" 🔗
void set_icon_name(value: StringName)
StringName get_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.
The key representing this dock in the editor's layout file. If empty, the dock's displayed name will be used instead.
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.
Color title_color = Color(0, 0, 0, 0) 🔗
The color of the dock tab's title. If its alpha is 0.0, the default font color will be used.
If true, the dock is not automatically opened or closed when loading an editor layout, only moved. It also can't be opened using a shortcut. This is meant for docks that are opened and closed in specific cases, such as when selecting a TileMap or AnimationTree node.
方法说明
void _load_layout_from_config(config: ConfigFile, section: String) 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(config: ConfigFile, section: String) 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(layout: int) virtual 🔗
Implement this method to handle the layout switching for this dock. layout is one of the DockLayout constants.
func _update_layout(layout):
box_container.vertical = (layout == DOCK_LAYOUT_VERTICAL)
void close() 🔗
Closes the dock, making its tab hidden.
void make_visible() 🔗
Focuses the dock's tab (or window if it's floating). If the dock was closed, it will be opened. If it's a bottom dock, makes the bottom panel visible.
void open() 🔗
Opens the dock. It will appear in the last used dock slot. If the dock has no default slot, it will be opened floating.
Note: This does not focus the dock. If you want to open and focus the dock, use make_visible().