Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

EditorPlugin

繼承: Node < Object

被繼承: GridMapEditorPlugin

由編輯器使用,用於擴充其功能。

說明

編輯器使用外掛程式來擴充功能。最常見的外掛程式型別是編輯給定的節點或資源型別的外掛程式、匯入外掛程式和匯出外掛程式。另請參閱 EditorScript 以向編輯器新增功能。

教學

方法

void

_apply_changes() virtual

bool

_build() virtual

void

_clear() virtual

void

_disable_plugin() virtual

void

_edit(object: Object) virtual

void

_enable_plugin() virtual

void

_forward_3d_draw_over_viewport(viewport_control: Control) virtual

void

_forward_3d_force_draw_over_viewport(viewport_control: Control) virtual

int

_forward_3d_gui_input(viewport_camera: Camera3D, event: InputEvent) virtual

void

_forward_canvas_draw_over_viewport(viewport_control: Control) virtual

void

_forward_canvas_force_draw_over_viewport(viewport_control: Control) virtual

bool

_forward_canvas_gui_input(event: InputEvent) virtual

PackedStringArray

_get_breakpoints() virtual const

Texture2D

_get_plugin_icon() virtual const

String

_get_plugin_name() virtual const

Dictionary

_get_state() virtual const

String

_get_unsaved_status(for_scene: String) virtual const

void

_get_window_layout(configuration: ConfigFile) virtual

bool

_handles(object: Object) virtual const

bool

_has_main_screen() virtual const

void

_make_visible(visible: bool) virtual

PackedStringArray

_run_scene(scene: String, args: PackedStringArray) virtual const

void

_save_external_data() virtual

void

_set_state(state: Dictionary) virtual

void

_set_window_layout(configuration: ConfigFile) virtual

void

add_autoload_singleton(name: String, path: String)

void

add_context_menu_plugin(slot: ContextMenuSlot, plugin: EditorContextMenuPlugin)

Button

add_control_to_bottom_panel(control: Control, title: String, shortcut: Shortcut = null)

void

add_control_to_container(container: CustomControlContainer, control: Control)

void

add_control_to_dock(slot: DockSlot, control: Control, shortcut: Shortcut = null)

void

add_custom_type(type: String, base: String, script: Script, icon: Texture2D)

void

add_debugger_plugin(script: EditorDebuggerPlugin)

void

add_dock(dock: EditorDock)

void

add_export_platform(platform: EditorExportPlatform)

void

add_export_plugin(plugin: EditorExportPlugin)

void

add_import_plugin(importer: EditorImportPlugin, first_priority: bool = false)

void

add_inspector_plugin(plugin: EditorInspectorPlugin)

void

add_node_3d_gizmo_plugin(plugin: EditorNode3DGizmoPlugin)

void

add_resource_conversion_plugin(plugin: EditorResourceConversionPlugin)

void

add_scene_format_importer_plugin(scene_format_importer: EditorSceneFormatImporter, first_priority: bool = false)

void

add_scene_post_import_plugin(scene_import_plugin: EditorScenePostImportPlugin, first_priority: bool = false)

void

add_tool_menu_item(name: String, callable: Callable)

void

add_tool_submenu_item(name: String, submenu: PopupMenu)

void

add_translation_parser_plugin(parser: EditorTranslationParserPlugin)

void

add_undo_redo_inspector_hook_callback(callable: Callable)

EditorInterface

get_editor_interface()

PopupMenu

get_export_as_menu()

String

get_plugin_version() const

ScriptCreateDialog

get_script_create_dialog()

EditorUndoRedoManager

get_undo_redo()

void

hide_bottom_panel()

void

make_bottom_panel_item_visible(item: Control)

void

queue_save_layout()

void

remove_autoload_singleton(name: String)

void

remove_context_menu_plugin(plugin: EditorContextMenuPlugin)

void

remove_control_from_bottom_panel(control: Control)

void

remove_control_from_container(container: CustomControlContainer, control: Control)

void

remove_control_from_docks(control: Control)

void

remove_custom_type(type: String)

void

remove_debugger_plugin(script: EditorDebuggerPlugin)

void

remove_dock(dock: EditorDock)

void

remove_export_platform(platform: EditorExportPlatform)

void

remove_export_plugin(plugin: EditorExportPlugin)

void

remove_import_plugin(importer: EditorImportPlugin)

void

remove_inspector_plugin(plugin: EditorInspectorPlugin)

void

remove_node_3d_gizmo_plugin(plugin: EditorNode3DGizmoPlugin)

void

remove_resource_conversion_plugin(plugin: EditorResourceConversionPlugin)

void

remove_scene_format_importer_plugin(scene_format_importer: EditorSceneFormatImporter)

void

remove_scene_post_import_plugin(scene_import_plugin: EditorScenePostImportPlugin)

void

remove_tool_menu_item(name: String)

void

remove_translation_parser_plugin(parser: EditorTranslationParserPlugin)

void

remove_undo_redo_inspector_hook_callback(callable: Callable)

void

set_dock_tab_icon(control: Control, icon: Texture2D)

void

set_force_draw_over_forwarding_enabled()

void

set_input_event_forwarding_always_enabled()

int

update_overlays() const


訊號

main_screen_changed(screen_name: String) 🔗

Emitted when user changes the workspace (2D, 3D, Script, Game, Asset Store). Also works with custom screens defined by plugins.


project_settings_changed() 🔗

已棄用: Use ProjectSettings.settings_changed instead.

Emitted when any project setting has changed.


resource_saved(resource: Resource) 🔗

Emitted when the given resource was saved on disc. See also scene_saved.


scene_changed(scene_root: Node) 🔗

在編輯器中更改場景時發出。該參數將返回剛剛變為活動狀態的場景的根節點。如果此場景是新場景且為空,則參數將為 null


scene_closed(filepath: String) 🔗

Emitted when user closes a scene. The argument is a file path to the closed scene.


scene_saved(filepath: String) 🔗

Emitted when a scene was saved on disc. The argument is a file path to the saved scene. See also resource_saved.


列舉

enum CustomControlContainer: 🔗

CustomControlContainer CONTAINER_TOOLBAR = 0

主編輯器的工具列,旁邊是運作按鈕。

CustomControlContainer CONTAINER_SPATIAL_EDITOR_MENU = 1

3D 編輯器處於活動狀態時出現的工具列。

CustomControlContainer CONTAINER_SPATIAL_EDITOR_SIDE_LEFT = 2

3D 編輯器的左側邊欄。

CustomControlContainer CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT = 3

3D 編輯器的右側邊欄。

CustomControlContainer CONTAINER_SPATIAL_EDITOR_BOTTOM = 4

3D 編輯器的底部面板。

CustomControlContainer CONTAINER_CANVAS_EDITOR_MENU = 5

2D 編輯器處於活動狀態時出現的工具條。

CustomControlContainer CONTAINER_CANVAS_EDITOR_SIDE_LEFT = 6

2D 編輯器的左側邊欄。

CustomControlContainer CONTAINER_CANVAS_EDITOR_SIDE_RIGHT = 7

2D 編輯器的右側邊欄。

CustomControlContainer CONTAINER_CANVAS_EDITOR_BOTTOM = 8

2D 編輯器的底部面板。

CustomControlContainer CONTAINER_INSPECTOR_BOTTOM = 9

屬性檢視器的底部區段。

CustomControlContainer CONTAINER_PROJECT_SETTING_TAB_LEFT = 10

專案設定對話方塊中的分頁,在其他分頁的左側。

CustomControlContainer CONTAINER_PROJECT_SETTING_TAB_RIGHT = 11

專案設定對話方塊中的分頁,在其他分頁的右側。


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

左側停靠槽的右下(預設佈局中為“檔案系統”面板)。

DockSlot DOCK_SLOT_RIGHT_UL = 4

停靠區位置,右側,左上方 (在預設版面配置中包含屬性檢視器、節點和歷史記錄停靠區)。

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 列舉的大小。


enum AfterGUIInput: 🔗

AfterGUIInput AFTER_GUI_INPUT_PASS = 0

將該 InputEvent 轉發給其他 EditorPlugin。

AfterGUIInput AFTER_GUI_INPUT_STOP = 1

阻止該 InputEvent 到達其他 Editor 類。

AfterGUIInput AFTER_GUI_INPUT_CUSTOM = 2

將該 InputEvent 傳遞給除主 Node3D 外掛程式之外的其他編輯器外掛程式。這可用於防止節點選擇更改並且改為使用子小工具。


方法說明

void _apply_changes() virtual 🔗

當編輯器將要進行保存專案、切換分頁等操作時,將呼叫該方法。它要求外掛程式套用所有暫掛的狀態更改以確保一致性。

例如,在著色器編輯器中使用它來使外掛程式將使用者編寫的著色程式碼套用於物件。


bool _build() virtual 🔗

該方法在編輯器即將運作專案時被呼叫。這樣,外掛程式可以在專案運作之前,執行所需的操作。

該方法必須返回一個布林值。如果該方法返回 false,則專案將不會運行。運作會立即中止,因此這也會阻止運作所有其他外掛程式的 _build() 方法。


void _clear() virtual 🔗

清除所有狀態,並將正在編輯的物件重設為零。這可確保你的外掛程式不會繼續編輯目前存在的節點或來自錯誤場景的節點。


void _disable_plugin() virtual 🔗

當使用者在專案設定視窗的外掛程式分頁中禁用 EditorPlugin 時,由引擎呼叫。


void _edit(object: Object) virtual 🔗

該函式用於編輯特定物件型別(節點或資源)的外掛程式。它請求編輯器編輯給定的對象。

如果該外掛程式剛剛正在編輯一個物件,且它不想再處理任何選定的物件,則 object 可以為 null。這可用於清理編輯狀態。


void _enable_plugin() virtual 🔗

當使用者在專案設定視窗的外掛程式分頁中啟用該 EditorPlugin 時,由引擎呼叫。


void _forward_3d_draw_over_viewport(viewport_control: Control) virtual 🔗

Called by the engine when the 3D editor's viewport is updated. viewport_control is an overlay on top of the viewport and it can be used for drawing. You can update the viewport manually by calling update_overlays().

func _forward_3d_draw_over_viewport(overlay):
    # Draw a circle at the cursor's position.
    overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.WHITE)

func _forward_3d_gui_input(camera, event):
    if event is InputEventMouseMotion:
        # Redraw the viewport when the cursor is moved.
        update_overlays()
        return EditorPlugin.AFTER_GUI_INPUT_STOP
    return EditorPlugin.AFTER_GUI_INPUT_PASS

void _forward_3d_force_draw_over_viewport(viewport_control: Control) virtual 🔗

該方法與 _forward_3d_draw_over_viewport() 相同,只是它繪製在所有內容之上。當需要一個顯示在其他任何內容之上的額外圖層時很有用。

需要使用 set_force_draw_over_forwarding_enabled() 來啟用該方法的呼叫。


int _forward_3d_gui_input(viewport_camera: Camera3D, event: InputEvent) virtual 🔗

Called when there is a root node in the current edited scene, _handles() is implemented, and an InputEvent happens in the 3D viewport. The return value decides whether the InputEvent is consumed or forwarded to other EditorPlugins. See AfterGUIInput for options.

# Prevents the InputEvent from reaching other Editor classes.
func _forward_3d_gui_input(camera, event):
    return EditorPlugin.AFTER_GUI_INPUT_STOP

This method must return AFTER_GUI_INPUT_PASS in order to forward the InputEvent to other Editor classes.

# Consumes InputEventMouseMotion and forwards other InputEvent types.
func _forward_3d_gui_input(camera, event):
    return EditorPlugin.AFTER_GUI_INPUT_STOP if event is InputEventMouseMotion else EditorPlugin.AFTER_GUI_INPUT_PASS

void _forward_canvas_draw_over_viewport(viewport_control: Control) virtual 🔗

Called by the engine when the 2D editor's viewport is updated. viewport_control is an overlay on top of the viewport and it can be used for drawing. You can update the viewport manually by calling update_overlays().

func _forward_canvas_draw_over_viewport(overlay):
    # Draw a circle at the cursor's position.
    overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.WHITE)

func _forward_canvas_gui_input(event):
    if event is InputEventMouseMotion:
        # Redraw the viewport when the cursor is moved.
        update_overlays()
        return true
    return false

void _forward_canvas_force_draw_over_viewport(viewport_control: Control) virtual 🔗

該方法與 _forward_canvas_draw_over_viewport() 相同,只是它繪製在所有內容之上。當需要一個顯示在其他任何內容之上的額外圖層時很有用。

需要使用 set_force_draw_over_forwarding_enabled() 來啟用該方法的呼叫。


bool _forward_canvas_gui_input(event: InputEvent) virtual 🔗

Called when there is a root node in the current edited scene, _handles() is implemented, and an InputEvent happens in the 2D viewport. If this method returns true, event is intercepted by this EditorPlugin, otherwise event is forwarded to other Editor classes.

# Prevents the InputEvent from reaching other Editor classes.
func _forward_canvas_gui_input(event):
    return true

This method must return false in order to forward the InputEvent to other Editor classes.

# Consumes InputEventMouseMotion and forwards other InputEvent types.
func _forward_canvas_gui_input(event):
    if (event is InputEventMouseMotion):
        return true
    return false

PackedStringArray _get_breakpoints() virtual const 🔗

該函式用於編輯基於腳本的物件的編輯器。可以返回格式為(script:line)的中斷點的列表,例如:res://path_to_script.gd:25


Texture2D _get_plugin_icon() virtual const 🔗

Override this method in your plugin to return a Texture2D in order to give it an icon.

For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", "Game", and "Asset Store" buttons.

Ideally, the plugin icon should be white with a transparent background and 16×16 pixels in size.

func _get_plugin_icon():
    # You can use a custom icon:
    return preload("res://addons/my_plugin/my_plugin_icon.svg")
    # Or use a built-in icon:
    return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")

String _get_plugin_name() virtual const 🔗

Override this method in your plugin to provide the name of the plugin when displayed in the Godot editor.

For main screen plugins, this appears at the top of the screen, to the right of the "2D", "3D", "Script", "Game", and "Asset Store" buttons.


Dictionary _get_state() virtual const 🔗

Override this method to provide a state data you want to be saved, like view position, grid settings, folding, etc. This is used when saving the scene (so state is kept when opening it again) and for switching tabs (so state can be restored when the tab returns). This data is automatically saved for each scene in an editstate file in the editor metadata folder. If you want to store global (scene-independent) editor data for your plugin, you can use _get_window_layout() instead.

Use _set_state() to restore your saved state.

Note: This method should not be used to save important settings that should persist with the project.

Note: You must implement _get_plugin_name() for the state to be stored and restored correctly.

func _get_state():
    var state = { "zoom": zoom, "preferred_color": my_color }
    return state

String _get_unsaved_status(for_scene: String) virtual const 🔗

重寫此方法以提供列出未儲存變更的自訂訊息。編輯器將在退出或關閉場景時呼叫此方法,並在確認對話方塊中顯示傳回的字元字串。傳回空如果插件沒有未儲存的更改,則為字串。

關閉場景時,for_scene 是正在關閉的場景的路徑。您可以使用它來處理該場景中的內建資源。

如果使用者確認儲存,將在關閉編輯器之前呼叫_save_external_data()

func _get_unsaved_status(for_scene):
    if not unsaved:
        return ""

    if for_scene.is_empty():
        return "Save changes in MyCustomPlugin before closing?"
    else:
        return "Scene %s has changes from MyCustomPlugin. Save before closing?" % for_scene.get_file()

func _save_external_data():
    unsaved = false

如果插件沒有特定於場景的更改,則可以在關閉場景時忽略呼叫:

func _get_unsaved_status(for_scene):
    if not for_scene.is_empty():
        return ""

void _get_window_layout(configuration: ConfigFile) virtual 🔗

覆蓋該方法,以提供該外掛程式的 GUI 佈局、或想要儲存的任何其他資料。這用於在呼叫 queue_save_layout()、或更改編輯器佈局(例如更改停靠面板的位置)時,保存專案的編輯器佈局。資料被儲存在編輯器中繼資料目錄中的 editor_layout.cfg 檔案中。

使用 _set_window_layout() 恢復保存的佈局。

func _get_window_layout(configuration):
    configuration.set_value("MyPlugin", "window_position", $Window.position)
    configuration.set_value("MyPlugin", "icon_color", $Icon.modulate)

bool _handles(object: Object) virtual const 🔗

Implement this function if your plugin edits a specific type of object (Resource or Node). If you return true, then you will get the functions _edit() and _make_visible() called when the editor requests them. If you have declared the methods _forward_canvas_gui_input() and _forward_3d_gui_input() these will be called too.

Note: Each plugin should handle only one type of objects at a time. If a plugin handles more types of objects and they are edited at the same time, it will result in errors.


bool _has_main_screen() virtual const 🔗

Returns true if this is a main screen editor plugin (it goes in the workspace selector together with 2D, 3D, Script, Game, and Asset Store).

When the plugin's workspace is selected, other main screen plugins will be hidden, but your plugin will not appear automatically. It needs to be added as a child of EditorInterface.get_editor_main_screen() and made visible inside _make_visible().

Use _get_plugin_name() and _get_plugin_icon() to customize the plugin button's appearance.

var plugin_control

func _enter_tree():
    plugin_control = preload("my_plugin_control.tscn").instantiate()
    EditorInterface.get_editor_main_screen().add_child(plugin_control)
    plugin_control.hide()

func _has_main_screen():
    return true

func _make_visible(visible):
    plugin_control.visible = visible

func _get_plugin_name():
    return "My Super Cool Plugin 3000"

func _get_plugin_icon():
    return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")

void _make_visible(visible: bool) virtual 🔗

當編輯器被要求變為可見時,該函式將被呼叫。它用於編輯特定物件型別的外掛程式。

請記住,你必須手動管理所有編輯器控制項的可見性。


PackedStringArray _run_scene(scene: String, args: PackedStringArray) virtual const 🔗

This function is called when an individual scene is about to be played in the editor. args is a list of command line arguments that will be passed to the new Godot instance, which will be replaced by the list returned by this function.

func _run_scene(scene, args):
    args.append("--an-extra-argument")
    return args

Note: Text that is printed in this method will not be visible in the editor's Output panel unless EditorSettings.run/output/always_clear_output_on_play is false.


void _save_external_data() virtual 🔗

這個方法在編輯器保存專案後或關閉專案時被呼叫,它要求外掛程式保存編輯的外部場景/資源。


void _set_state(state: Dictionary) virtual 🔗

恢復用 _get_state() 保存的狀態。這個方法會在編輯器的目前場景分頁發生改變時呼叫。

注意:你的外掛程式必須實作 _get_plugin_name(),否則無法被識別,這個方法也不會被呼叫。

func _set_state(data):
    zoom = data.get("zoom", 1.0)
    preferred_color = data.get("my_color", Color.WHITE)

void _set_window_layout(configuration: ConfigFile) virtual 🔗

恢復用 _get_window_layout() 保存的外掛程式 GUI 佈局和資料。編輯器啟動時會呼叫每個外掛程式的這個方法。請使用提供的 configuration 檔讀取你保存的數據。

func _set_window_layout(configuration):
    $Window.position = configuration.get_value("MyPlugin", "window_position", Vector2())
    $Icon.modulate = configuration.get_value("MyPlugin", "icon_color", Color.WHITE)

void add_autoload_singleton(name: String, path: String) 🔗

path 處的腳本作為 name 新增到自動載入列表中。


void add_context_menu_plugin(slot: ContextMenuSlot, plugin: EditorContextMenuPlugin) 🔗

Adds a plugin to the context menu. slot is the context menu where the plugin will be added.

Note: A plugin instance can belong only to a single context menu slot.


Button add_control_to_bottom_panel(control: Control, title: String, shortcut: Shortcut = null) 🔗

已棄用: Use add_dock() instead, with EditorDock.default_slot set to DOCK_SLOT_BOTTOM.

Adds a control to the bottom panel (together with Output, Debug, Animation, etc.). Returns a reference to a button that is outside the scene tree. It's up to you to hide/show the button when needed. When your plugin is deactivated, make sure to remove your custom control with remove_control_from_bottom_panel() and free it with Node.queue_free().

shortcut is a shortcut that, when activated, will toggle the bottom panel's visibility. The shortcut object is only set when this control is added to the bottom panel.

Note See the default editor bottom panel shortcuts in the Editor Settings for inspiration. By convention, they all use Alt modifier.


void add_control_to_container(container: CustomControlContainer, control: Control) 🔗

Adds a custom control to a container in the editor UI.

Please remember that you have to manage the visibility of your custom controls yourself (and likely hide it after adding it).

When your plugin is deactivated, make sure to remove your custom control with remove_control_from_container() and free it with Node.queue_free().


void add_control_to_dock(slot: DockSlot, control: Control, shortcut: Shortcut = null) 🔗

已棄用: Use add_dock() instead.

Adds the control to a specific dock slot.

If the dock is repositioned and as long as the plugin is active, the editor will save the dock position on further sessions.

When your plugin is deactivated, make sure to remove your custom control with remove_control_from_docks() and free it with Node.queue_free().

Optionally, you can specify a shortcut parameter. When pressed, this shortcut will open and focus the dock.


void add_custom_type(type: String, base: String, script: Script, icon: Texture2D) 🔗

Adds a custom type, which will appear in the list of nodes or resources.

When a given node or resource is selected, the base type will be instantiated (e.g. "Node3D", "Control", "Resource"), then the script will be loaded and set to this object.

Note: The base type is the base engine class which this type's class hierarchy inherits, not any custom type parent classes.

You can use the virtual method _handles() to check if your custom object is being edited by checking the script or using the is keyword.

During run-time, this will be a simple object with a script so this function does not need to be called then.

Note: Custom types added this way are not true classes. They are just a helper to create a node with specific script.


void add_debugger_plugin(script: EditorDebuggerPlugin) 🔗

將一個 Script 作為除錯器外掛程式新增到除錯器。該腳本必須擴充 EditorDebuggerPlugin


void add_dock(dock: EditorDock) 🔗

Adds a new dock.

When your plugin is deactivated, make sure to remove your custom dock with remove_dock() and free it with Node.queue_free().


void add_export_platform(platform: EditorExportPlatform) 🔗

Registers a new EditorExportPlatform. Export platforms provides functionality of exporting to the specific platform.


void add_export_plugin(plugin: EditorExportPlugin) 🔗

註冊一個新的 EditorExportPlugin。匯出外掛程式是用來在專案被匯出時執行工作的。

有關如何註冊外掛程式的範例,請參見 add_inspector_plugin()


void add_import_plugin(importer: EditorImportPlugin, first_priority: bool = false) 🔗

註冊一個新的 EditorImportPlugin。匯入外掛程式用於將自訂的和不受支援的素材,作為一種自訂 Resource 型別匯入。

如果 first_prioritytrue,則該新的匯入外掛程式被首先插入列表中,並優先於預先存在的外掛程式。

注意:如果要匯入自訂 3D 素材格式,請改用 add_scene_format_importer_plugin()

有關如何註冊外掛程式的範例,請參見 add_inspector_plugin()


void add_inspector_plugin(plugin: EditorInspectorPlugin) 🔗

註冊一個新的 EditorInspectorPlugin。屬性檢視器外掛程式用於擴充 EditorInspector,並為您的物件屬性提供自訂設定工具。

注意: 務必在您的 EditorPlugin 被停用時,使用 remove_inspector_plugin() 來移除已註冊的 EditorInspectorPlugin,以防止記憶體洩漏以及非預期的行為。

const MyInspectorPlugin = preload("res://addons/your_addon/path/to/your/script.gd")
var inspector_plugin = MyInspectorPlugin.new()

func _enter_tree():
    add_inspector_plugin(inspector_plugin)

func _exit_tree():
    remove_inspector_plugin(inspector_plugin)

void add_node_3d_gizmo_plugin(plugin: EditorNode3DGizmoPlugin) 🔗

註冊一個新的 EditorNode3DGizmoPlugin。小工具外掛程式用於將自訂小工具新增到 Node3D 的 3D 預覽視圖。

有關如何註冊外掛程式的範例,請參閱 add_inspector_plugin()


void add_resource_conversion_plugin(plugin: EditorResourceConversionPlugin) 🔗

註冊一個新的 EditorResourceConversionPlugin。資源轉換外掛程式用於新增自訂資源轉換器到編輯器屬性檢視器。

請參閱 EditorResourceConversionPlugin,以取得如何建立資源轉換外掛程式的範例。


void add_scene_format_importer_plugin(scene_format_importer: EditorSceneFormatImporter, first_priority: bool = false) 🔗

註冊一個新的 EditorSceneFormatImporter。場景匯入器用於將自訂格式的 3D 資產匯入為場景。

如果 first_prioritytrue,則這個新的匯入外掛程式會被插入到列表的首位,優先於預先存在的外掛程式。


void add_scene_post_import_plugin(scene_import_plugin: EditorScenePostImportPlugin, first_priority: bool = false) 🔗

Add an EditorScenePostImportPlugin. These plugins allow customizing the import process of 3D assets by adding new options to the import dialogs.

If first_priority is true, the new import plugin is inserted first in the list and takes precedence over pre-existing plugins.


void add_tool_menu_item(name: String, callable: Callable) 🔗

專案 > 工具中新增名為 name 的自訂功能表專案。點擊時會呼叫所提供的 callable


void add_tool_submenu_item(name: String, submenu: PopupMenu) 🔗

Adds a custom PopupMenu submenu under Project > Tools > name. Use remove_tool_menu_item() on plugin clean up to remove the menu.


void add_translation_parser_plugin(parser: EditorTranslationParserPlugin) 🔗

註冊一個自訂翻譯解析器外掛程式,用於從自訂檔中提取可翻譯的字串。


void add_undo_redo_inspector_hook_callback(callable: Callable) 🔗

掛鉤一個回呼函式到當屬性在屬性檢視器中被修改時的復原/重做動作建立過程。這允許例如儲存當指定的屬性被修改時可能會遺失的其他屬性。

該回呼函式應該有 4 個引數:Object undo_redoObject modified_objectString property 以及 Variant new_value。它們分別是屬性檢視器使用的 UndoRedo 物件、目前被修改的物件、被修改屬性的名稱,以及該屬性即將採用的新值。


EditorInterface get_editor_interface() 🔗

已棄用: EditorInterface is a global singleton and can be accessed directly by its name.

Returns the EditorInterface singleton instance.


PopupMenu get_export_as_menu() 🔗

返回場景 > 另存為...下的 PopupMenu


String get_plugin_version() const 🔗

提供 plugin.cfg 設定檔中宣告的外掛程式版本。


ScriptCreateDialog get_script_create_dialog() 🔗

獲取用於建立腳本的編輯器對話方塊。

注意:使用者可以在使用前對其進行配置。

警告:移除和釋放這個節點將使編輯器的一部分失去作用,並可能導致當機。


EditorUndoRedoManager get_undo_redo() 🔗

獲取撤銷/重做對象。編輯器中的大多數操作都是可以撤銷的,因此請使用此物件來確保在需要時執行此操作。


void hide_bottom_panel() 🔗

最小化底部面板。


void make_bottom_panel_item_visible(item: Control) 🔗

使底部面板中的一個特定專案可見。


void queue_save_layout() 🔗

排隊保存遊戲專案的編輯器佈局。


void remove_autoload_singleton(name: String) 🔗

從列表中移除自動載入 name


void remove_context_menu_plugin(plugin: EditorContextMenuPlugin) 🔗

Removes the specified context menu plugin.


void remove_control_from_bottom_panel(control: Control) 🔗

已棄用: Use remove_dock() instead.

從底部面板上移除該控制項。必須手動呼叫 Node.queue_free() 釋放該控制項。


void remove_control_from_container(container: CustomControlContainer, control: Control) 🔗

從指定的容器中移除該控制項。必須手動呼叫 Node.queue_free() 釋放該控制項。


void remove_control_from_docks(control: Control) 🔗

已棄用: Use remove_dock() instead.

從停靠面板中移除該控制項。必須手動呼叫 Node.queue_free() 釋放該控制項。


void remove_custom_type(type: String) 🔗

移除由 add_custom_type() 新增的自訂型別。


void remove_debugger_plugin(script: EditorDebuggerPlugin) 🔗

從除錯器中移除帶有給定腳本的除錯器外掛程式。


void remove_dock(dock: EditorDock) 🔗

Removes dock from the available docks. You should manually call Node.queue_free() to free it.


void remove_export_platform(platform: EditorExportPlatform) 🔗

Removes an export platform registered by add_export_platform().


void remove_export_plugin(plugin: EditorExportPlugin) 🔗

移除由 add_export_plugin() 註冊的匯出外掛程式。


void remove_import_plugin(importer: EditorImportPlugin) 🔗

移除由 add_import_plugin() 註冊的匯入外掛程式。


void remove_inspector_plugin(plugin: EditorInspectorPlugin) 🔗

移除由 add_inspector_plugin() 註冊的屬性檢視器外掛程式。


void remove_node_3d_gizmo_plugin(plugin: EditorNode3DGizmoPlugin) 🔗

移除由 add_node_3d_gizmo_plugin() 註冊的小工具外掛程式。


void remove_resource_conversion_plugin(plugin: EditorResourceConversionPlugin) 🔗

移除由 add_resource_conversion_plugin() 註冊的資源轉換外掛程式。


void remove_scene_format_importer_plugin(scene_format_importer: EditorSceneFormatImporter) 🔗

移除由 add_scene_format_importer_plugin() 註冊的場景格式匯入器外掛程式。


void remove_scene_post_import_plugin(scene_import_plugin: EditorScenePostImportPlugin) 🔗

移除由 add_scene_post_import_plugin() 註冊的 EditorScenePostImportPlugin


void remove_tool_menu_item(name: String) 🔗

專案 > 工具中移除名為 name 的選單。


void remove_translation_parser_plugin(parser: EditorTranslationParserPlugin) 🔗

移除由 add_translation_parser_plugin() 註冊的自訂翻譯解析器外掛程式。


void remove_undo_redo_inspector_hook_callback(callable: Callable) 🔗

移除由 add_undo_redo_inspector_hook_callback() 新增的回呼函式。


void set_dock_tab_icon(control: Control, icon: Texture2D) 🔗

已棄用: Use EditorDock.dock_icon instead.

Sets the tab icon for the given control in a dock slot. Setting to null removes the icon.


void set_force_draw_over_forwarding_enabled() 🔗

更新視口時,為 2D 編輯器啟用 _forward_canvas_force_draw_over_viewport() 的呼叫,為 3D 編輯器啟用 _forward_3d_force_draw_over_viewport() 的呼叫。只需呼叫該方法一次,它將永久適用於該外掛程式。


void set_input_event_forwarding_always_enabled() 🔗

如果始終希望從 3D 視圖螢幕在 _forward_3d_gui_input() 中接收輸入,請使用該方法。如果外掛程式想要在場景中使用射線投射,它可能特別有用。


int update_overlays() const 🔗

更新 2D 和 3D 編輯器視口的疊加層。會導致方法 _forward_canvas_draw_over_viewport()_forward_canvas_force_draw_over_viewport()_forward_3d_draw_over_viewport()_forward_3d_force_draw_over_viewport() 被呼叫。