mirror of
https://github.com/godotengine/godot-docs-l10n.git
synced 2026-01-04 10:09:56 +03:00
1657 lines
93 KiB
ReStructuredText
1657 lines
93 KiB
ReStructuredText
:github_url: hide
|
||
|
||
.. DO NOT EDIT THIS FILE!!!
|
||
.. Generated automatically from Godot engine sources.
|
||
.. Generator: https://github.com/godotengine/godot/tree/4.2/doc/tools/make_rst.py.
|
||
.. XML source: https://github.com/godotengine/godot/tree/4.2/doc/classes/EditorPlugin.xml.
|
||
|
||
.. _class_EditorPlugin:
|
||
|
||
EditorPlugin
|
||
============
|
||
|
||
**继承:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
|
||
|
||
由编辑器使用,用于扩展其功能。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
描述
|
||
----
|
||
|
||
编辑器使用插件来扩展功能。最常见的插件类型是编辑给定的节点或资源类型的插件、导入插件和导出插件。另见 :ref:`EditorScript<class_EditorScript>`\ ,能够向编辑器添加功能。
|
||
|
||
\ **注意:**\ 这个类中的部分名称中包含“left”和“right”(例如 :ref:`DOCK_SLOT_LEFT_UL<class_EditorPlugin_constant_DOCK_SLOT_LEFT_UL>`\ )。这些 API 假设的是从左至右的布局,使用从右至左布局时是反的。保留这些名称是出于兼容的原因。
|
||
|
||
.. rst-class:: classref-introduction-group
|
||
|
||
教程
|
||
----
|
||
|
||
- :doc:`编辑器插件文档索引 <../tutorials/plugins/editor/index>`
|
||
|
||
.. rst-class:: classref-reftable-group
|
||
|
||
方法
|
||
----
|
||
|
||
.. table::
|
||
:widths: auto
|
||
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_apply_changes<class_EditorPlugin_private_method__apply_changes>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_build<class_EditorPlugin_private_method__build>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_clear<class_EditorPlugin_private_method__clear>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_disable_plugin<class_EditorPlugin_private_method__disable_plugin>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_edit<class_EditorPlugin_private_method__edit>` **(** :ref:`Object<class_Object>` object **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_enable_plugin<class_EditorPlugin_private_method__enable_plugin>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_forward_3d_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_draw_over_viewport>` **(** :ref:`Control<class_Control>` viewport_control **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_forward_3d_force_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_force_draw_over_viewport>` **(** :ref:`Control<class_Control>` viewport_control **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`_forward_3d_gui_input<class_EditorPlugin_private_method__forward_3d_gui_input>` **(** :ref:`Camera3D<class_Camera3D>` viewport_camera, :ref:`InputEvent<class_InputEvent>` event **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_forward_canvas_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_draw_over_viewport>` **(** :ref:`Control<class_Control>` viewport_control **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_forward_canvas_force_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_force_draw_over_viewport>` **(** :ref:`Control<class_Control>` viewport_control **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_forward_canvas_gui_input<class_EditorPlugin_private_method__forward_canvas_gui_input>` **(** :ref:`InputEvent<class_InputEvent>` event **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PackedStringArray<class_PackedStringArray>` | :ref:`_get_breakpoints<class_EditorPlugin_private_method__get_breakpoints>` **(** **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Texture2D<class_Texture2D>` | :ref:`_get_plugin_icon<class_EditorPlugin_private_method__get_plugin_icon>` **(** **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_plugin_name<class_EditorPlugin_private_method__get_plugin_name>` **(** **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Dictionary<class_Dictionary>` | :ref:`_get_state<class_EditorPlugin_private_method__get_state>` **(** **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`_get_unsaved_status<class_EditorPlugin_private_method__get_unsaved_status>` **(** :ref:`String<class_String>` for_scene **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_get_window_layout<class_EditorPlugin_private_method__get_window_layout>` **(** :ref:`ConfigFile<class_ConfigFile>` configuration **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_handles<class_EditorPlugin_private_method__handles>` **(** :ref:`Object<class_Object>` object **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`bool<class_bool>` | :ref:`_has_main_screen<class_EditorPlugin_private_method__has_main_screen>` **(** **)** |virtual| |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_make_visible<class_EditorPlugin_private_method__make_visible>` **(** :ref:`bool<class_bool>` visible **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_save_external_data<class_EditorPlugin_private_method__save_external_data>` **(** **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_set_state<class_EditorPlugin_private_method__set_state>` **(** :ref:`Dictionary<class_Dictionary>` state **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`_set_window_layout<class_EditorPlugin_private_method__set_window_layout>` **(** :ref:`ConfigFile<class_ConfigFile>` configuration **)** |virtual| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_autoload_singleton<class_EditorPlugin_method_add_autoload_singleton>` **(** :ref:`String<class_String>` name, :ref:`String<class_String>` path **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`Button<class_Button>` | :ref:`add_control_to_bottom_panel<class_EditorPlugin_method_add_control_to_bottom_panel>` **(** :ref:`Control<class_Control>` control, :ref:`String<class_String>` title **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_control_to_container<class_EditorPlugin_method_add_control_to_container>` **(** :ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` container, :ref:`Control<class_Control>` control **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_control_to_dock<class_EditorPlugin_method_add_control_to_dock>` **(** :ref:`DockSlot<enum_EditorPlugin_DockSlot>` slot, :ref:`Control<class_Control>` control **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_custom_type<class_EditorPlugin_method_add_custom_type>` **(** :ref:`String<class_String>` type, :ref:`String<class_String>` base, :ref:`Script<class_Script>` script, :ref:`Texture2D<class_Texture2D>` icon **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_debugger_plugin<class_EditorPlugin_method_add_debugger_plugin>` **(** :ref:`EditorDebuggerPlugin<class_EditorDebuggerPlugin>` script **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_export_plugin<class_EditorPlugin_method_add_export_plugin>` **(** :ref:`EditorExportPlugin<class_EditorExportPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_import_plugin<class_EditorPlugin_method_add_import_plugin>` **(** :ref:`EditorImportPlugin<class_EditorImportPlugin>` importer, :ref:`bool<class_bool>` first_priority=false **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_inspector_plugin<class_EditorPlugin_method_add_inspector_plugin>` **(** :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_node_3d_gizmo_plugin<class_EditorPlugin_method_add_node_3d_gizmo_plugin>` **(** :ref:`EditorNode3DGizmoPlugin<class_EditorNode3DGizmoPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_resource_conversion_plugin<class_EditorPlugin_method_add_resource_conversion_plugin>` **(** :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_scene_format_importer_plugin<class_EditorPlugin_method_add_scene_format_importer_plugin>` **(** :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>` scene_format_importer, :ref:`bool<class_bool>` first_priority=false **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_scene_post_import_plugin<class_EditorPlugin_method_add_scene_post_import_plugin>` **(** :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>` scene_import_plugin, :ref:`bool<class_bool>` first_priority=false **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_tool_menu_item<class_EditorPlugin_method_add_tool_menu_item>` **(** :ref:`String<class_String>` name, :ref:`Callable<class_Callable>` callable **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_tool_submenu_item<class_EditorPlugin_method_add_tool_submenu_item>` **(** :ref:`String<class_String>` name, :ref:`PopupMenu<class_PopupMenu>` submenu **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_translation_parser_plugin<class_EditorPlugin_method_add_translation_parser_plugin>` **(** :ref:`EditorTranslationParserPlugin<class_EditorTranslationParserPlugin>` parser **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`add_undo_redo_inspector_hook_callback<class_EditorPlugin_method_add_undo_redo_inspector_hook_callback>` **(** :ref:`Callable<class_Callable>` callable **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`EditorInterface<class_EditorInterface>` | :ref:`get_editor_interface<class_EditorPlugin_method_get_editor_interface>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`PopupMenu<class_PopupMenu>` | :ref:`get_export_as_menu<class_EditorPlugin_method_get_export_as_menu>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`String<class_String>` | :ref:`get_plugin_version<class_EditorPlugin_method_get_plugin_version>` **(** **)** |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`ScriptCreateDialog<class_ScriptCreateDialog>` | :ref:`get_script_create_dialog<class_EditorPlugin_method_get_script_create_dialog>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`EditorUndoRedoManager<class_EditorUndoRedoManager>` | :ref:`get_undo_redo<class_EditorPlugin_method_get_undo_redo>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`hide_bottom_panel<class_EditorPlugin_method_hide_bottom_panel>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`make_bottom_panel_item_visible<class_EditorPlugin_method_make_bottom_panel_item_visible>` **(** :ref:`Control<class_Control>` item **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`queue_save_layout<class_EditorPlugin_method_queue_save_layout>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_autoload_singleton<class_EditorPlugin_method_remove_autoload_singleton>` **(** :ref:`String<class_String>` name **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_control_from_bottom_panel<class_EditorPlugin_method_remove_control_from_bottom_panel>` **(** :ref:`Control<class_Control>` control **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_control_from_container<class_EditorPlugin_method_remove_control_from_container>` **(** :ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` container, :ref:`Control<class_Control>` control **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_control_from_docks<class_EditorPlugin_method_remove_control_from_docks>` **(** :ref:`Control<class_Control>` control **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_custom_type<class_EditorPlugin_method_remove_custom_type>` **(** :ref:`String<class_String>` type **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_debugger_plugin<class_EditorPlugin_method_remove_debugger_plugin>` **(** :ref:`EditorDebuggerPlugin<class_EditorDebuggerPlugin>` script **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_export_plugin<class_EditorPlugin_method_remove_export_plugin>` **(** :ref:`EditorExportPlugin<class_EditorExportPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_import_plugin<class_EditorPlugin_method_remove_import_plugin>` **(** :ref:`EditorImportPlugin<class_EditorImportPlugin>` importer **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_inspector_plugin<class_EditorPlugin_method_remove_inspector_plugin>` **(** :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_node_3d_gizmo_plugin<class_EditorPlugin_method_remove_node_3d_gizmo_plugin>` **(** :ref:`EditorNode3DGizmoPlugin<class_EditorNode3DGizmoPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_resource_conversion_plugin<class_EditorPlugin_method_remove_resource_conversion_plugin>` **(** :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>` plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_scene_format_importer_plugin<class_EditorPlugin_method_remove_scene_format_importer_plugin>` **(** :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>` scene_format_importer **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_scene_post_import_plugin<class_EditorPlugin_method_remove_scene_post_import_plugin>` **(** :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>` scene_import_plugin **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_tool_menu_item<class_EditorPlugin_method_remove_tool_menu_item>` **(** :ref:`String<class_String>` name **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_translation_parser_plugin<class_EditorPlugin_method_remove_translation_parser_plugin>` **(** :ref:`EditorTranslationParserPlugin<class_EditorTranslationParserPlugin>` parser **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`remove_undo_redo_inspector_hook_callback<class_EditorPlugin_method_remove_undo_redo_inspector_hook_callback>` **(** :ref:`Callable<class_Callable>` callable **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`set_force_draw_over_forwarding_enabled<class_EditorPlugin_method_set_force_draw_over_forwarding_enabled>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| void | :ref:`set_input_event_forwarding_always_enabled<class_EditorPlugin_method_set_input_event_forwarding_always_enabled>` **(** **)** |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
| :ref:`int<class_int>` | :ref:`update_overlays<class_EditorPlugin_method_update_overlays>` **(** **)** |const| |
|
||
+-----------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
信号
|
||
----
|
||
|
||
.. _class_EditorPlugin_signal_main_screen_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**main_screen_changed** **(** :ref:`String<class_String>` screen_name **)**
|
||
|
||
当用户改变工作空间(\ **2D**\ 、\ **3D**\ 、\ **Script**\ 、\ **AssetLib**\ )时发出。也适用于由插件定义的自定义屏幕。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_signal_project_settings_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**project_settings_changed** **(** **)**
|
||
|
||
当任意项目设置发生改变时发出。
|
||
|
||
\ *已废弃。*\ 请改用 :ref:`ProjectSettings.settings_changed<class_ProjectSettings_signal_settings_changed>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_signal_resource_saved:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**resource_saved** **(** :ref:`Resource<class_Resource>` resource **)**
|
||
|
||
给定的资源 ``resource`` 保存到磁盘时发出。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_signal_scene_changed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**scene_changed** **(** :ref:`Node<class_Node>` scene_root **)**
|
||
|
||
在编辑器中更改场景时发出。该参数将返回刚刚变为活动状态的场景的根节点。如果此场景是新场景且为空,则参数将为 ``null``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_signal_scene_closed:
|
||
|
||
.. rst-class:: classref-signal
|
||
|
||
**scene_closed** **(** :ref:`String<class_String>` filepath **)**
|
||
|
||
当用户关闭场景时发出。参数是关闭的场景的文件路径。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
枚举
|
||
----
|
||
|
||
.. _enum_EditorPlugin_CustomControlContainer:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **CustomControlContainer**:
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_TOOLBAR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_TOOLBAR** = ``0``
|
||
|
||
主编辑器的工具栏,旁边是运行按钮。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_SPATIAL_EDITOR_MENU:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_SPATIAL_EDITOR_MENU** = ``1``
|
||
|
||
3D 编辑器处于活动状态时出现的工具栏。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_SPATIAL_EDITOR_SIDE_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_SPATIAL_EDITOR_SIDE_LEFT** = ``2``
|
||
|
||
3D 编辑器的左侧边栏。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT** = ``3``
|
||
|
||
3D 编辑器的右侧边栏。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_SPATIAL_EDITOR_BOTTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_SPATIAL_EDITOR_BOTTOM** = ``4``
|
||
|
||
3D 编辑器的底部面板。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_CANVAS_EDITOR_MENU:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_CANVAS_EDITOR_MENU** = ``5``
|
||
|
||
2D 编辑器处于活动状态时出现的工具条。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_CANVAS_EDITOR_SIDE_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_CANVAS_EDITOR_SIDE_LEFT** = ``6``
|
||
|
||
2D 编辑器的左侧边栏。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_CANVAS_EDITOR_SIDE_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_CANVAS_EDITOR_SIDE_RIGHT** = ``7``
|
||
|
||
2D 编辑器的右侧边栏。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_CANVAS_EDITOR_BOTTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_CANVAS_EDITOR_BOTTOM** = ``8``
|
||
|
||
2D 编辑器的底部面板。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_INSPECTOR_BOTTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_INSPECTOR_BOTTOM** = ``9``
|
||
|
||
检查器的底部。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_PROJECT_SETTING_TAB_LEFT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_PROJECT_SETTING_TAB_LEFT** = ``10``
|
||
|
||
项目设置对话框中的选项卡,在其他选项卡的左侧。
|
||
|
||
.. _class_EditorPlugin_constant_CONTAINER_PROJECT_SETTING_TAB_RIGHT:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` **CONTAINER_PROJECT_SETTING_TAB_RIGHT** = ``11``
|
||
|
||
项目设置对话框中的选项卡,在其他选项卡的右侧。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_EditorPlugin_DockSlot:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **DockSlot**:
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_LEFT_UL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_LEFT_UL** = ``0``
|
||
|
||
左侧停靠槽的左上(默认布局中为空)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_LEFT_BL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_LEFT_BL** = ``1``
|
||
|
||
左侧停靠槽的左下(默认布局中为空)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_LEFT_UR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_LEFT_UR** = ``2``
|
||
|
||
左侧停靠槽的右上(默认布局中为“场景”和“导入”面板)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_LEFT_BR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_LEFT_BR** = ``3``
|
||
|
||
左侧停靠槽的右下(默认布局中为“文件系统”面板)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_RIGHT_UL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_RIGHT_UL** = ``4``
|
||
|
||
右侧停靠槽的左上(默认布局中为“检查器”“节点”以及“历史”面板)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_RIGHT_BL:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_RIGHT_BL** = ``5``
|
||
|
||
右侧停靠槽的左下(默认布局中为空)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_RIGHT_UR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_RIGHT_UR** = ``6``
|
||
|
||
右侧停靠槽的右上(默认布局中为空)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_RIGHT_BR:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_RIGHT_BR** = ``7``
|
||
|
||
右侧停靠槽的右下(默认布局中为空)。
|
||
|
||
.. _class_EditorPlugin_constant_DOCK_SLOT_MAX:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`DockSlot<enum_EditorPlugin_DockSlot>` **DOCK_SLOT_MAX** = ``8``
|
||
|
||
代表 :ref:`DockSlot<enum_EditorPlugin_DockSlot>` 枚举的大小。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _enum_EditorPlugin_AfterGUIInput:
|
||
|
||
.. rst-class:: classref-enumeration
|
||
|
||
enum **AfterGUIInput**:
|
||
|
||
.. _class_EditorPlugin_constant_AFTER_GUI_INPUT_PASS:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AfterGUIInput<enum_EditorPlugin_AfterGUIInput>` **AFTER_GUI_INPUT_PASS** = ``0``
|
||
|
||
将该 :ref:`InputEvent<class_InputEvent>` 转发给其他 EditorPlugin。
|
||
|
||
.. _class_EditorPlugin_constant_AFTER_GUI_INPUT_STOP:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AfterGUIInput<enum_EditorPlugin_AfterGUIInput>` **AFTER_GUI_INPUT_STOP** = ``1``
|
||
|
||
阻止该 :ref:`InputEvent<class_InputEvent>` 到达其他 Editor 类。
|
||
|
||
.. _class_EditorPlugin_constant_AFTER_GUI_INPUT_CUSTOM:
|
||
|
||
.. rst-class:: classref-enumeration-constant
|
||
|
||
:ref:`AfterGUIInput<enum_EditorPlugin_AfterGUIInput>` **AFTER_GUI_INPUT_CUSTOM** = ``2``
|
||
|
||
将该 :ref:`InputEvent<class_InputEvent>` 传递给除主 :ref:`Node3D<class_Node3D>` 插件之外的其他编辑器插件。这可用于防止节点选择更改并且改为使用子小工具。
|
||
|
||
.. rst-class:: classref-section-separator
|
||
|
||
----
|
||
|
||
.. rst-class:: classref-descriptions-group
|
||
|
||
方法说明
|
||
--------
|
||
|
||
.. _class_EditorPlugin_private_method__apply_changes:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_apply_changes** **(** **)** |virtual|
|
||
|
||
当编辑器将要进行保存项目、切换选项卡等操作时,将调用该方法。它要求插件应用所有暂挂的状态更改以确保一致性。
|
||
|
||
例如,在着色器编辑器中使用它来使插件将用户编写的着色代码应用于对象。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__build:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_build** **(** **)** |virtual|
|
||
|
||
该方法在编辑器即将运行项目时被调用。这样,插件可以在项目运行之前,执行所需的操作。
|
||
|
||
该方法必须返回一个布尔值。如果该方法返回 ``false``\ ,则项目将不会运行。运行会立即中止,因此这也会阻止运行所有其他插件的 :ref:`_build<class_EditorPlugin_private_method__build>` 方法。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__clear:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_clear** **(** **)** |virtual|
|
||
|
||
清除所有状态,并将正在编辑的对象重置为零。这可确保你的插件不会继续编辑当前存在的节点或来自错误场景的节点。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__disable_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_disable_plugin** **(** **)** |virtual|
|
||
|
||
当用户在项目设置窗口的插件选项卡中禁用 **EditorPlugin** 时,由引擎调用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__edit:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_edit** **(** :ref:`Object<class_Object>` object **)** |virtual|
|
||
|
||
该函数用于编辑特定对象类型(节点或资源)的插件。它请求编辑器编辑给定的对象。
|
||
|
||
如果该插件刚刚正在编辑一个对象,且它不想再处理任何选定的对象,则 ``object`` 可以为 ``null``\ 。这可用于清理编辑状态。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__enable_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_enable_plugin** **(** **)** |virtual|
|
||
|
||
当用户在项目设置窗口的插件选项卡中启用该 **EditorPlugin** 时,由引擎调用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_3d_draw_over_viewport:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_forward_3d_draw_over_viewport** **(** :ref:`Control<class_Control>` viewport_control **)** |virtual|
|
||
|
||
当 3D 编辑器的视口更新时由引擎调用。将 ``overlay`` :ref:`Control<class_Control>` 用于绘制。可以通过调用 :ref:`update_overlays<class_EditorPlugin_method_update_overlays>` 手动更新该视口。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _forward_3d_draw_over_viewport(overlay):
|
||
# 在光标位置画一个圆。
|
||
overlay.draw_circle(overlay.get_local_mouse_position(), 64)
|
||
|
||
func _forward_3d_gui_input(camera, event):
|
||
if event is InputEventMouseMotion:
|
||
# 当光标被移动时,重绘视口。
|
||
update_overlays()
|
||
return EditorPlugin.AFTER_GUI_INPUT_STOP
|
||
return EditorPlugin.AFTER_GUI_INPUT_PASS
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override void _Forward3DDrawOverViewport(Control viewportControl)
|
||
{
|
||
// 在光标位置画一个圆。
|
||
viewportControl.DrawCircle(viewportControl.GetLocalMousePosition(), 64, Colors.White);
|
||
}
|
||
|
||
public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D viewportCamera, InputEvent @event)
|
||
{
|
||
if (@event is InputEventMouseMotion)
|
||
{
|
||
// 当光标被移动时,重绘视口。
|
||
UpdateOverlays();
|
||
return EditorPlugin.AfterGuiInput.Stop;
|
||
}
|
||
return EditorPlugin.AfterGuiInput.Pass;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_3d_force_draw_over_viewport:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_forward_3d_force_draw_over_viewport** **(** :ref:`Control<class_Control>` viewport_control **)** |virtual|
|
||
|
||
该方法与 :ref:`_forward_3d_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_draw_over_viewport>` 相同,只是它绘制在所有内容之上。当需要一个显示在其他任何内容之上的额外图层时很有用。
|
||
|
||
需要使用 :ref:`set_force_draw_over_forwarding_enabled<class_EditorPlugin_method_set_force_draw_over_forwarding_enabled>` 来启用该方法的调用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_3d_gui_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **_forward_3d_gui_input** **(** :ref:`Camera3D<class_Camera3D>` viewport_camera, :ref:`InputEvent<class_InputEvent>` event **)** |virtual|
|
||
|
||
在当前编辑的场景中有根节点时调用,实现 :ref:`_handles<class_EditorPlugin_private_method__handles>` 并在 3D 视口中产生 :ref:`InputEvent<class_InputEvent>`\ 。返回值决定 :ref:`InputEvent<class_InputEvent>` 是被消费还是被转发给其他 **EditorPlugin**\ 。有关选项,请参阅 :ref:`AfterGUIInput<enum_EditorPlugin_AfterGUIInput>`\ 。
|
||
|
||
\ **示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 阻止 InputEvent 到达其他编辑类。
|
||
func _forward_3d_gui_input(camera, event):
|
||
return EditorPlugin.AFTER_GUI_INPUT_STOP
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 阻止 InputEvent 到达其他编辑类。
|
||
public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
|
||
{
|
||
return EditorPlugin.AfterGuiInput.Stop;
|
||
}
|
||
|
||
|
||
|
||
必须为 ``return EditorPlugin.AFTER_GUI_INPUT_PASS`` 以便将 :ref:`InputEvent<class_InputEvent>` 转发给其他编辑器类。
|
||
|
||
\ **示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 消耗 InputEventMouseMotion 并转发其他 InputEvent 类型。
|
||
func _forward_3d_gui_input(camera, event):
|
||
return EditorPlugin.AFTER_GUI_INPUT_STOP if event is InputEventMouseMotion else EditorPlugin.AFTER_GUI_INPUT_PASS
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 消耗 InputEventMouseMotion 并转发其他 InputEvent 类型。
|
||
public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
|
||
{
|
||
return @event is InputEventMouseMotion ? EditorPlugin.AfterGuiInput.Stop : EditorPlugin.AfterGuiInput.Pass;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_canvas_draw_over_viewport:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_forward_canvas_draw_over_viewport** **(** :ref:`Control<class_Control>` viewport_control **)** |virtual|
|
||
|
||
当 2D 编辑器的视口更新时由引擎调用。将 ``overlay`` :ref:`Control<class_Control>` 用于绘制。可以通过调用 :ref:`update_overlays<class_EditorPlugin_method_update_overlays>` 手动更新该视口。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _forward_canvas_draw_over_viewport(overlay):
|
||
# 在光标位置画一个圆。
|
||
overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.WHITE)
|
||
|
||
func _forward_canvas_gui_input(event):
|
||
if event is InputEventMouseMotion:
|
||
# 当光标被移动时,重绘视口。
|
||
update_overlays()
|
||
return true
|
||
return false
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override void _ForwardCanvasDrawOverViewport(Control viewportControl)
|
||
{
|
||
// 在光标位置画一个圆。
|
||
viewportControl.DrawCircle(viewportControl.GetLocalMousePosition(), 64, Colors.White);
|
||
}
|
||
|
||
public override bool _ForwardCanvasGuiInput(InputEvent @event)
|
||
{
|
||
if (@event is InputEventMouseMotion)
|
||
{
|
||
// 当光标被移动时,重绘视口。
|
||
UpdateOverlays();
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_canvas_force_draw_over_viewport:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_forward_canvas_force_draw_over_viewport** **(** :ref:`Control<class_Control>` viewport_control **)** |virtual|
|
||
|
||
该方法与 :ref:`_forward_canvas_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_draw_over_viewport>` 相同,只是它绘制在所有内容之上。当需要一个显示在其他任何内容之上的额外图层时很有用。
|
||
|
||
需要使用 :ref:`set_force_draw_over_forwarding_enabled<class_EditorPlugin_method_set_force_draw_over_forwarding_enabled>` 来启用该方法的调用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__forward_canvas_gui_input:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_forward_canvas_gui_input** **(** :ref:`InputEvent<class_InputEvent>` event **)** |virtual|
|
||
|
||
在当前编辑的场景中有根节点时调用,实现 :ref:`_handles<class_EditorPlugin_private_method__handles>` 并在 2D 视口中产生 :ref:`InputEvent<class_InputEvent>`\ 。如果 ``return true`` **EditorPlugin** 消耗 ``event``\ ,则拦截该 :ref:`InputEvent<class_InputEvent>`\ ;否则将 ``event`` 转发给其他编辑器类。
|
||
|
||
\ **示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 阻止 InputEvent 到达其他编辑类。
|
||
func _forward_canvas_gui_input(event):
|
||
return true
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 阻止 InputEvent 到达其他编辑类。
|
||
public override bool ForwardCanvasGuiInput(InputEvent @event)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
|
||
|
||
必须 ``return false`` 才能将 :ref:`InputEvent<class_InputEvent>` 转发到其他编辑器类。
|
||
|
||
\ **示例:**\
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
# 消耗 InputEventMouseMotion 并转发其他 InputEvent 类型。
|
||
func _forward_canvas_gui_input(event):
|
||
if (event is InputEventMouseMotion):
|
||
return true
|
||
return false
|
||
|
||
.. code-tab:: csharp
|
||
|
||
// 消耗 InputEventMouseMotion 并转发其他 InputEvent 类型。
|
||
public override bool _ForwardCanvasGuiInput(InputEvent @event)
|
||
{
|
||
if (@event is InputEventMouseMotion)
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_breakpoints:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PackedStringArray<class_PackedStringArray>` **_get_breakpoints** **(** **)** |virtual| |const|
|
||
|
||
该函数用于编辑基于脚本的对象的编辑器。可以返回格式为(\ ``script:line``\ )的断点的列表,例如:\ ``res://path_to_script.gd:25``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_plugin_icon:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Texture2D<class_Texture2D>` **_get_plugin_icon** **(** **)** |virtual| |const|
|
||
|
||
在插件中覆盖该方法,以返回一个 :ref:`Texture2D<class_Texture2D>` 以便为插件提供一个图标。
|
||
|
||
对于主界面插件,它出现在屏幕顶部,“2D”、“3D”、“脚本”和 “AssetLib” 按钮的右侧。
|
||
|
||
理想情况下,插件图标应为透明背景的白色,大小为 16x16 像素。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
func _get_plugin_icon():
|
||
# 你可以使用一个自定义的图标:
|
||
return preload("res://addons/my_plugin/my_plugin_icon.svg")
|
||
# 或者使用一个内置的图标:
|
||
return EditorInterface.get_editor_theme().get_icon("Node", "EditorIcons")
|
||
|
||
.. code-tab:: csharp
|
||
|
||
public override Texture2D _GetPluginIcon()
|
||
{
|
||
// 你可以使用一个自定义的图标:
|
||
return ResourceLoader.Load<Texture2D>("res://addons/my_plugin/my_plugin_icon.svg");
|
||
// 或者使用一个内置的图标:
|
||
return EditorInterface.Singleton.GetEditorTheme().GetIcon("Node", "EditorIcons");
|
||
}
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_plugin_name:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_plugin_name** **(** **)** |virtual| |const|
|
||
|
||
在插件中覆盖该方法,以在 Godot 编辑器中显示时提供该插件的名称。
|
||
|
||
对于主屏幕插件,它显示在屏幕顶部,在“2D”“3D”“脚本”“AssetLib”按钮的右侧。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_state:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Dictionary<class_Dictionary>` **_get_state** **(** **)** |virtual| |const|
|
||
|
||
覆盖该方法,以提供要保存的状态数据,如视图位置、网格设置、折叠等。这可用于保存场景(再次打开时,保持状态)和切换选项卡( 选项卡返回时,可以恢复状态)。每个场景的数据会自动被保存在编辑器元数据文件夹中的 ``editstate`` 文件中。如果想为插件存储全局的(独立于场景的)编辑器数据,可以改用 :ref:`_get_window_layout<class_EditorPlugin_private_method__get_window_layout>`\ 。
|
||
|
||
使用 :ref:`_set_state<class_EditorPlugin_private_method__set_state>` 恢复保存的状态。
|
||
|
||
\ **注意:**\ 此方法不应该用于保存应随项目保留的重要设置。
|
||
|
||
\ **注意:**\ 必须实现 :ref:`_get_plugin_name<class_EditorPlugin_private_method__get_plugin_name>`\ ,才能正确存储和恢复状态。
|
||
|
||
::
|
||
|
||
func _get_state():
|
||
var state = {"zoom": zoom, "preferred_color": my_color}
|
||
return state
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_unsaved_status:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **_get_unsaved_status** **(** :ref:`String<class_String>` for_scene **)** |virtual| |const|
|
||
|
||
覆盖该方法以提供列出未保存更改的自定义消息。编辑器将在退出或关闭场景时调用该方法,并在确认对话框中显示返回的字符串。如果该插件没有未保存的更改,则返回空字符串。
|
||
|
||
关闭场景时,\ ``for_scene`` 是正在关闭的场景的路径。你可以使用它来处理该场景中的内置资源。
|
||
|
||
如果用户确认保存,将在关闭编辑器之前将调用 :ref:`_save_external_data<class_EditorPlugin_private_method__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 ""
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__get_window_layout:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_get_window_layout** **(** :ref:`ConfigFile<class_ConfigFile>` configuration **)** |virtual|
|
||
|
||
覆盖该方法,以提供该插件的 GUI 布局、或想要存储的任何其他数据。这用于在调用 :ref:`queue_save_layout<class_EditorPlugin_method_queue_save_layout>`\ 、或更改编辑器布局(例如更改停靠面板的位置)时,保存项目的编辑器布局。数据被存储在编辑器元数据目录中的 ``editor_layout.cfg`` 文件中。
|
||
|
||
使用 :ref:`_set_window_layout<class_EditorPlugin_private_method__set_window_layout>` 恢复保存的布局。
|
||
|
||
::
|
||
|
||
func _get_window_layout(configuration):
|
||
configuration.set_value("MyPlugin", "window_position", $Window.position)
|
||
configuration.set_value("MyPlugin", "icon_color", $Icon.modulate)
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__handles:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_handles** **(** :ref:`Object<class_Object>` object **)** |virtual| |const|
|
||
|
||
如果插件会编辑特定类型的对象(资源或节点),则请实现该函数。如果返回 ``true``\ ,则将在编辑器请求时,调用函数 :ref:`_edit<class_EditorPlugin_private_method__edit>` 和 :ref:`_make_visible<class_EditorPlugin_private_method__make_visible>`\ 。如果已经声明了方法 :ref:`_forward_canvas_gui_input<class_EditorPlugin_private_method__forward_canvas_gui_input>` 和 :ref:`_forward_3d_gui_input<class_EditorPlugin_private_method__forward_3d_gui_input>`\ ,则它们也会被调用。
|
||
|
||
\ **注意:**\ 每个插件一次只应处理一种类型的对象。如果一个插件处理多种类型的对象并且同时编辑这些对象,则会导致错误。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__has_main_screen:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`bool<class_bool>` **_has_main_screen** **(** **)** |virtual| |const|
|
||
|
||
如果这是一个主屏幕编辑器插件,则返回 ``true``\ (它与 **2D**\ 、\ **3D**\ 、\ **Script** 和 **AssetLib** 一起进入工作区选择器)。
|
||
|
||
当该插件的工作区被选中时,其他主屏幕插件将被隐藏,但你的插件不会自动出现。它需要被添加为 :ref:`EditorInterface.get_base_control<class_EditorInterface_method_get_base_control>` 的子节点,并在 :ref:`_make_visible<class_EditorPlugin_private_method__make_visible>` 中使其可见。
|
||
|
||
使用 :ref:`_get_plugin_name<class_EditorPlugin_private_method__get_plugin_name>` 和 :ref:`_get_plugin_icon<class_EditorPlugin_private_method__get_plugin_icon>` 自定义插件按钮的外观。
|
||
|
||
::
|
||
|
||
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")
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__make_visible:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_make_visible** **(** :ref:`bool<class_bool>` visible **)** |virtual|
|
||
|
||
当编辑器被要求变为可见时,该函数将被调用。它用于编辑特定对象类型的插件。
|
||
|
||
请记住,你必须手动管理所有编辑器控件的可见性。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__save_external_data:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_save_external_data** **(** **)** |virtual|
|
||
|
||
这个方法在编辑器保存项目后或关闭项目时被调用,它要求插件保存编辑的外部场景/资源。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__set_state:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_set_state** **(** :ref:`Dictionary<class_Dictionary>` state **)** |virtual|
|
||
|
||
恢复用 :ref:`_get_state<class_EditorPlugin_private_method__get_state>` 保存的状态。这个方法会在编辑器的当前场景选项卡发生改变时调用。
|
||
|
||
\ **注意:**\ 你的插件必须实现 :ref:`_get_plugin_name<class_EditorPlugin_private_method__get_plugin_name>`\ ,否则无法被识别,这个方法也不会被调用。
|
||
|
||
::
|
||
|
||
func _set_state(data):
|
||
zoom = data.get("zoom", 1.0)
|
||
preferred_color = data.get("my_color", Color.WHITE)
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_private_method__set_window_layout:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **_set_window_layout** **(** :ref:`ConfigFile<class_ConfigFile>` configuration **)** |virtual|
|
||
|
||
恢复用 :ref:`_get_window_layout<class_EditorPlugin_private_method__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)
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_autoload_singleton:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_autoload_singleton** **(** :ref:`String<class_String>` name, :ref:`String<class_String>` path **)**
|
||
|
||
将 ``path`` 处的脚本作为 ``name`` 添加到自动加载列表中。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_control_to_bottom_panel:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`Button<class_Button>` **add_control_to_bottom_panel** **(** :ref:`Control<class_Control>` control, :ref:`String<class_String>` title **)**
|
||
|
||
将控件添加到底部面板(包含“输出”“调试”“动画”等)。返回对添加的按钮的引用。可以根据需要隐藏/显示按钮。停用插件后,请确保使用 :ref:`remove_control_from_bottom_panel<class_EditorPlugin_method_remove_control_from_bottom_panel>` 移除自定义控件,并使用 :ref:`Node.queue_free<class_Node_method_queue_free>` 将其释放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_control_to_container:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_control_to_container** **(** :ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` container, :ref:`Control<class_Control>` control **)**
|
||
|
||
将自定义控件添加到容器中(见 :ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>`\ )。在编辑器用户界面中,有许多位置可以添加自定义控件。
|
||
|
||
请记住,必须自己管理你的自定义控件的可见性(并且很可能在添加后隐藏它)。
|
||
|
||
当插件被停用时,请确保使用 :ref:`remove_control_from_container<class_EditorPlugin_method_remove_control_from_container>` 移除自定义控件,并使用 :ref:`Node.queue_free<class_Node_method_queue_free>` 将其释放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_control_to_dock:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_control_to_dock** **(** :ref:`DockSlot<enum_EditorPlugin_DockSlot>` slot, :ref:`Control<class_Control>` control **)**
|
||
|
||
将控件添加到特定的停靠面板(有关选项,请参阅 :ref:`DockSlot<enum_EditorPlugin_DockSlot>`\ )。
|
||
|
||
如果重新放置了停靠面板,并且只要该插件处于活动状态,编辑器就会在以后的会话中保存停靠面板的位置。
|
||
|
||
停用插件后,请确保使用 :ref:`remove_control_from_docks<class_EditorPlugin_method_remove_control_from_docks>` 移除自定义控件,并使用 :ref:`Node.queue_free<class_Node_method_queue_free>` 将其释放。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_custom_type:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_custom_type** **(** :ref:`String<class_String>` type, :ref:`String<class_String>` base, :ref:`Script<class_Script>` script, :ref:`Texture2D<class_Texture2D>` icon **)**
|
||
|
||
添加一个自定义类型,它将出现在节点或资源的列表中。可以选择传递一个图标。
|
||
|
||
选择给定的节点或资源时,将实例化基本类型(例如“Node3D”、“Control”、“Resource”),然后脚本将被加载并将其设置为该对象。
|
||
|
||
\ **注意:**\ 基本类型是该类型的类层次继承的基本引擎类,而不是任何自定义类型的父类。
|
||
|
||
可以使用虚方法 :ref:`_handles<class_EditorPlugin_private_method__handles>` 通过检查脚本或使用 ``is`` 关键字来检查你的自定义对象是否正在被编辑。
|
||
|
||
在运行时,这将是一个带有脚本的简单对象,因此不需要调用该函数。
|
||
|
||
\ **注意:**\ 以这种方式添加的自定义类型不是真正的类。它们只是使用特定脚本创建节点的助手。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_debugger_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_debugger_plugin** **(** :ref:`EditorDebuggerPlugin<class_EditorDebuggerPlugin>` script **)**
|
||
|
||
将一个 :ref:`Script<class_Script>` 作为调试器插件添加到调试器。该脚本必须扩展 :ref:`EditorDebuggerPlugin<class_EditorDebuggerPlugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_export_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_export_plugin** **(** :ref:`EditorExportPlugin<class_EditorExportPlugin>` plugin **)**
|
||
|
||
注册一个新的 :ref:`EditorExportPlugin<class_EditorExportPlugin>`\ 。导出插件是用来在项目被导出时执行任务的。
|
||
|
||
有关如何注册插件的示例,请参见 :ref:`add_inspector_plugin<class_EditorPlugin_method_add_inspector_plugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_import_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_import_plugin** **(** :ref:`EditorImportPlugin<class_EditorImportPlugin>` importer, :ref:`bool<class_bool>` first_priority=false **)**
|
||
|
||
注册一个新的 :ref:`EditorImportPlugin<class_EditorImportPlugin>`\ 。导入插件用于将自定义的和不受支持的资产,作为一种自定义 :ref:`Resource<class_Resource>` 类型导入。
|
||
|
||
如果 ``first_priority`` 是 ``true``\ ,则该新的导入插件被首先插入列表中,并优先于预先存在的插件。
|
||
|
||
\ **注意:**\ 如果要导入自定义 3D 资产格式,请改用 :ref:`add_scene_format_importer_plugin<class_EditorPlugin_method_add_scene_format_importer_plugin>`\ 。
|
||
|
||
有关如何注册插件的示例,请参见 :ref:`add_inspector_plugin<class_EditorPlugin_method_add_inspector_plugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_inspector_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_inspector_plugin** **(** :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>` plugin **)**
|
||
|
||
注册一个新的 :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>`\ 。检查器插件用于扩展 :ref:`EditorInspector<class_EditorInspector>`\ ,并为对象的属性提供自定义配置工具。
|
||
|
||
\ **注意:**\ 当 **EditorPlugin** 被禁用时,请始终使用 :ref:`remove_inspector_plugin<class_EditorPlugin_method_remove_inspector_plugin>` 移除已注册的 :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>`\ ,以防止泄漏和意外行为。
|
||
|
||
|
||
.. tabs::
|
||
|
||
.. code-tab:: gdscript
|
||
|
||
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)
|
||
|
||
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_node_3d_gizmo_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_node_3d_gizmo_plugin** **(** :ref:`EditorNode3DGizmoPlugin<class_EditorNode3DGizmoPlugin>` plugin **)**
|
||
|
||
注册一个新的 :ref:`EditorNode3DGizmoPlugin<class_EditorNode3DGizmoPlugin>`\ 。小工具插件用于将自定义小工具添加到 :ref:`Node3D<class_Node3D>` 的 3D 预览视图。
|
||
|
||
有关如何注册插件的示例,请参阅 :ref:`add_inspector_plugin<class_EditorPlugin_method_add_inspector_plugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_resource_conversion_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_resource_conversion_plugin** **(** :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>` plugin **)**
|
||
|
||
注册一个新的 :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>`\ 。资源转换插件用于将自定义资源转换器添加到编辑器检查器。
|
||
|
||
有关如何创建资源转换插件的示例,请参阅 :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_scene_format_importer_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_scene_format_importer_plugin** **(** :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>` scene_format_importer, :ref:`bool<class_bool>` first_priority=false **)**
|
||
|
||
注册一个新的 :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>`\ 。场景导入器用于将自定义格式的 3D 资产导入为场景。
|
||
|
||
如果 ``first_priority`` 为 ``true``\ ,则这个新的导入插件会被插入到列表的首位,优先于预先存在的插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_scene_post_import_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_scene_post_import_plugin** **(** :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>` scene_import_plugin, :ref:`bool<class_bool>` first_priority=false **)**
|
||
|
||
添加 :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>`\ 。这些插件能够在导入对话框中添加新的选项,自定义 3D 资产的导入过程。
|
||
|
||
如果 ``first_priority`` 为 ``true``\ ,则这个新的导入插件会被插入到列表的首位,优先于预先存在的插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_tool_menu_item:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_tool_menu_item** **(** :ref:`String<class_String>` name, :ref:`Callable<class_Callable>` callable **)**
|
||
|
||
在\ **项目 > 工具**\ 中添加名为 ``name`` 的自定义菜单项。点击时会调用所提供的 ``callable``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_tool_submenu_item:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_tool_submenu_item** **(** :ref:`String<class_String>` name, :ref:`PopupMenu<class_PopupMenu>` submenu **)**
|
||
|
||
在\ **项目 > 工具**\ 中添加名为 ``name`` 的自定义 :ref:`PopupMenu<class_PopupMenu>` 子菜单。请在清理插件时调用 :ref:`remove_tool_menu_item<class_EditorPlugin_method_remove_tool_menu_item>` 移除该菜单。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_translation_parser_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_translation_parser_plugin** **(** :ref:`EditorTranslationParserPlugin<class_EditorTranslationParserPlugin>` parser **)**
|
||
|
||
注册一个自定义翻译解析器插件,用于从自定义文件中提取可翻译的字符串。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_add_undo_redo_inspector_hook_callback:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **add_undo_redo_inspector_hook_callback** **(** :ref:`Callable<class_Callable>` callable **)**
|
||
|
||
当在检查器中修改属性时,将一个回调函数挂钩到撤消/重做动作创建中。例如,这允许保存在修改给定属性时可能丢失的其他属性。
|
||
|
||
该回调函数应该有 4 个参数:\ :ref:`Object<class_Object>` ``undo_redo``\ 、\ :ref:`Object<class_Object>` ``modified_object``\ 、\ :ref:`String<class_String>` ``property``\ 、和 :ref:`Variant<class_Variant>` ``new_value``\ 。它们分别是检查器使用的 :ref:`UndoRedo<class_UndoRedo>` 对象、当前修改的对象、修改的属性的名称、和该属性即将采用的新值。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_get_editor_interface:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`EditorInterface<class_EditorInterface>` **get_editor_interface** **(** **)**
|
||
|
||
返回 :ref:`EditorInterface<class_EditorInterface>` 单例实例。
|
||
|
||
\ *已废弃。*\ :ref:`EditorInterface<class_EditorInterface>` 是全局单例,可以使用其名称直接访问。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_get_export_as_menu:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`PopupMenu<class_PopupMenu>` **get_export_as_menu** **(** **)**
|
||
|
||
返回\ **场景 > 另存为...**\ 下的 :ref:`PopupMenu<class_PopupMenu>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_get_plugin_version:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`String<class_String>` **get_plugin_version** **(** **)** |const|
|
||
|
||
提供在 ``plugin.cfg`` 配置文件中声明的插件版本。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_get_script_create_dialog:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`ScriptCreateDialog<class_ScriptCreateDialog>` **get_script_create_dialog** **(** **)**
|
||
|
||
获取用于创建脚本的编辑器对话框。
|
||
|
||
\ **注意:**\ 用户可以在使用前对其进行配置。
|
||
|
||
\ **警告:**\ 移除和释放这个节点将使编辑器的一部分失去作用,并可能导致崩溃。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_get_undo_redo:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`EditorUndoRedoManager<class_EditorUndoRedoManager>` **get_undo_redo** **(** **)**
|
||
|
||
获取撤消/重做对象。编辑器中的大多数操作都是可以撤消的,因此请使用此对象来确保在需要时执行此操作。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_hide_bottom_panel:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **hide_bottom_panel** **(** **)**
|
||
|
||
最小化底部面板。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_make_bottom_panel_item_visible:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **make_bottom_panel_item_visible** **(** :ref:`Control<class_Control>` item **)**
|
||
|
||
使底部面板中的一个特定项目可见。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_queue_save_layout:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **queue_save_layout** **(** **)**
|
||
|
||
排队保存游戏项目的编辑器布局。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_autoload_singleton:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_autoload_singleton** **(** :ref:`String<class_String>` name **)**
|
||
|
||
从列表中移除自动加载 ``name``\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_control_from_bottom_panel:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_control_from_bottom_panel** **(** :ref:`Control<class_Control>` control **)**
|
||
|
||
从底部面板上移除该控件。必须手动调用 :ref:`Node.queue_free<class_Node_method_queue_free>` 释放该控件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_control_from_container:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_control_from_container** **(** :ref:`CustomControlContainer<enum_EditorPlugin_CustomControlContainer>` container, :ref:`Control<class_Control>` control **)**
|
||
|
||
从指定的容器中移除该控件。必须手动调用 :ref:`Node.queue_free<class_Node_method_queue_free>` 释放该控件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_control_from_docks:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_control_from_docks** **(** :ref:`Control<class_Control>` control **)**
|
||
|
||
从停靠面板中移除该控件。必须手动调用 :ref:`Node.queue_free<class_Node_method_queue_free>` 释放该控件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_custom_type:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_custom_type** **(** :ref:`String<class_String>` type **)**
|
||
|
||
移除由 :ref:`add_custom_type<class_EditorPlugin_method_add_custom_type>` 添加的自定义类型。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_debugger_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_debugger_plugin** **(** :ref:`EditorDebuggerPlugin<class_EditorDebuggerPlugin>` script **)**
|
||
|
||
从调试器中移除带有给定脚本的调试器插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_export_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_export_plugin** **(** :ref:`EditorExportPlugin<class_EditorExportPlugin>` plugin **)**
|
||
|
||
移除由 :ref:`add_export_plugin<class_EditorPlugin_method_add_export_plugin>` 注册的导出插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_import_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_import_plugin** **(** :ref:`EditorImportPlugin<class_EditorImportPlugin>` importer **)**
|
||
|
||
移除由 :ref:`add_import_plugin<class_EditorPlugin_method_add_import_plugin>` 注册的导入插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_inspector_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_inspector_plugin** **(** :ref:`EditorInspectorPlugin<class_EditorInspectorPlugin>` plugin **)**
|
||
|
||
移除由 :ref:`add_import_plugin<class_EditorPlugin_method_add_import_plugin>` 注册的检查器插件
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_node_3d_gizmo_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_node_3d_gizmo_plugin** **(** :ref:`EditorNode3DGizmoPlugin<class_EditorNode3DGizmoPlugin>` plugin **)**
|
||
|
||
移除由 :ref:`add_node_3d_gizmo_plugin<class_EditorPlugin_method_add_node_3d_gizmo_plugin>` 注册的小工具插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_resource_conversion_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_resource_conversion_plugin** **(** :ref:`EditorResourceConversionPlugin<class_EditorResourceConversionPlugin>` plugin **)**
|
||
|
||
移除由 :ref:`add_resource_conversion_plugin<class_EditorPlugin_method_add_resource_conversion_plugin>` 注册的资源转换插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_scene_format_importer_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_scene_format_importer_plugin** **(** :ref:`EditorSceneFormatImporter<class_EditorSceneFormatImporter>` scene_format_importer **)**
|
||
|
||
移除由 :ref:`add_scene_format_importer_plugin<class_EditorPlugin_method_add_scene_format_importer_plugin>` 注册的场景格式导入器插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_scene_post_import_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_scene_post_import_plugin** **(** :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>` scene_import_plugin **)**
|
||
|
||
移除由 :ref:`add_scene_post_import_plugin<class_EditorPlugin_method_add_scene_post_import_plugin>` 注册的 :ref:`EditorScenePostImportPlugin<class_EditorScenePostImportPlugin>`\ 。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_tool_menu_item:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_tool_menu_item** **(** :ref:`String<class_String>` name **)**
|
||
|
||
从\ **项目 > 工具**\ 中移除名为 ``name`` 的菜单。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_translation_parser_plugin:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_translation_parser_plugin** **(** :ref:`EditorTranslationParserPlugin<class_EditorTranslationParserPlugin>` parser **)**
|
||
|
||
移除由 :ref:`add_translation_parser_plugin<class_EditorPlugin_method_add_translation_parser_plugin>` 注册的自定义翻译解析器插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_remove_undo_redo_inspector_hook_callback:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **remove_undo_redo_inspector_hook_callback** **(** :ref:`Callable<class_Callable>` callable **)**
|
||
|
||
移除由 :ref:`add_undo_redo_inspector_hook_callback<class_EditorPlugin_method_add_undo_redo_inspector_hook_callback>` 添加的回调。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_set_force_draw_over_forwarding_enabled:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **set_force_draw_over_forwarding_enabled** **(** **)**
|
||
|
||
更新视口时,为 2D 编辑器启用 :ref:`_forward_canvas_force_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_force_draw_over_viewport>` 的调用,为 3D 编辑器启用 :ref:`_forward_3d_force_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_force_draw_over_viewport>` 的调用。只需调用该方法一次,它将永久适用于该插件。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_set_input_event_forwarding_always_enabled:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
void **set_input_event_forwarding_always_enabled** **(** **)**
|
||
|
||
如果始终希望从 3D 视图屏幕在 :ref:`_forward_3d_gui_input<class_EditorPlugin_private_method__forward_3d_gui_input>` 中接收输入,请使用该方法。如果插件想要在场景中使用射线投射,它可能特别有用。
|
||
|
||
.. rst-class:: classref-item-separator
|
||
|
||
----
|
||
|
||
.. _class_EditorPlugin_method_update_overlays:
|
||
|
||
.. rst-class:: classref-method
|
||
|
||
:ref:`int<class_int>` **update_overlays** **(** **)** |const|
|
||
|
||
更新 2D 和 3D 编辑器视口的叠加层。会导致方法 :ref:`_forward_canvas_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_draw_over_viewport>`\ 、\ :ref:`_forward_canvas_force_draw_over_viewport<class_EditorPlugin_private_method__forward_canvas_force_draw_over_viewport>`\ 、\ :ref:`_forward_3d_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_draw_over_viewport>` 和 :ref:`_forward_3d_force_draw_over_viewport<class_EditorPlugin_private_method__forward_3d_force_draw_over_viewport>` 被调用。
|
||
|
||
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
|
||
.. |const| replace:: :abbr:`const (本方法没有副作用。不会修改该实例的任何成员变量。)`
|
||
.. |vararg| replace:: :abbr:`vararg (本方法除了在此处描述的参数外,还能够继续接受任意数量的参数。)`
|
||
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
|
||
.. |static| replace:: :abbr:`static (调用本方法无需实例,所以可以直接使用类名调用。)`
|
||
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效操作符。)`
|
||
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列标志构成的位掩码整数。)`
|