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.
Checking the stable version of the documentation...
EditorPlugin
被繼承: GridMapEditorPlugin
由編輯器使用,用於擴充其功能。
說明
編輯器使用外掛來擴充功能。最常見的外掛型別是編輯給定的節點或資源型別的外掛、匯入外掛和匯出外掛。另見 EditorScript,能夠向編輯器新增功能。
注意:這個類中的部分名稱中包含“left”和“right”(例如 DOCK_SLOT_LEFT_UL)。這些 API 假設的是從左至右的版面配置,使用從右至左版面配置時是反的。保留這些名稱是出於相容的原因。
教學
方法
訊號
main_screen_changed(screen_name: String) 🔗
當使用者切換工作區(2D、3D、腳本、遊戲、素材商店)時觸發。該訊號同樣適用於由外掛定義的自訂螢幕。
project_settings_changed() 🔗
已棄用: Use ProjectSettings.settings_changed instead.
當任意專案設定發生改變時觸發。
resource_saved(resource: Resource) 🔗
給定的資源 resource 儲存到磁碟時發出。另見 scene_saved。
scene_changed(scene_root: Node) 🔗
在編輯器中更改場景時發出。該參數將返回剛剛變為活動狀態的場景的根節點。如果此場景是新場景且為空,則參數將為 null。
scene_closed(filepath: String) 🔗
當使用者關閉場景時發出。參數是被關閉的場景的檔案路徑。
scene_saved(filepath: String) 🔗
當場景被儲存在磁碟上時發出。參數是被儲存的場景的檔案路徑。另見 resource_saved。
列舉
enum CustomControlContainer: 🔗
CustomControlContainer CONTAINER_TOOLBAR = 0
主編輯器的工具列,旁邊是運作按鈕。
3D 編輯器處於活動狀態時出現的工具列。
CustomControlContainer CONTAINER_SPATIAL_EDITOR_SIDE_LEFT = 2
3D 編輯器的左側邊欄。
CustomControlContainer CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT = 3
3D 編輯器的右側邊欄。
CustomControlContainer CONTAINER_SPATIAL_EDITOR_BOTTOM = 4
3D 編輯器的底部面板。
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
停靠面板是關閉的。
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
底部面板。
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 🔗
當編輯器將要進行保存專案、切換分頁等操作時,將呼叫該方法。它要求外掛程式套用所有暫掛的狀態更改以確保一致性。
例如,在著色器編輯器中使用它來使外掛程式將使用者編寫的著色程式碼套用於物件。
該方法在編輯器即將運作專案時被呼叫。這樣,外掛程式可以在專案運作之前,執行所需的操作。
該方法必須返回一個布林值。如果該方法返回 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 🔗
當 3D 編輯器的視埠更新時由引擎呼叫。viewport_control 覆蓋在視埠上方,可以用於繪製。可以通過呼叫 update_overlays() 手動更新該視埠。
func _forward_3d_draw_over_viewport(overlay):
# 在游標位置畫一個圓。
overlay.draw_circle(overlay.get_local_mouse_position(), 64, Color.WHITE)
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
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;
}
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 🔗
在目前編輯的場景中有根節點時呼叫,實作 _handles() 並在 3D 視埠中產生 InputEvent。回傳值決定 InputEvent 是被消費還是被轉發給其他 EditorPlugin。有關選項,請參閱 AfterGUIInput。
# 阻止 InputEvent 到達其他編輯類。
func _forward_3d_gui_input(camera, event):
return EditorPlugin.AFTER_GUI_INPUT_STOP
// 阻止 InputEvent 到達其他編輯類。
public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
{
return EditorPlugin.AfterGuiInput.Stop;
}
該方法回傳 AFTER_GUI_INPUT_PASS 才能將 InputEvent 轉發給其他編輯器類。
# 消耗 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
// 消耗 InputEventMouseMotion 並轉發其他 InputEvent 型別。
public override EditorPlugin.AfterGuiInput _Forward3DGuiInput(Camera3D camera, InputEvent @event)
{
return @event is InputEventMouseMotion ? EditorPlugin.AfterGuiInput.Stop : EditorPlugin.AfterGuiInput.Pass;
}
void _forward_canvas_draw_over_viewport(viewport_control: Control) virtual 🔗
當 2D 編輯器的視埠更新時由引擎呼叫。viewport_control 覆蓋在視埠上方,可以用於繪製。可以通過呼叫 update_overlays() 手動更新該視埠。
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
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;
}
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 🔗
在目前編輯的場景中有根節點時呼叫,實作 _handles() 並在 2D 視埠中產生 InputEvent。如果該方法回傳 true,則 EditorPlugin 會攔截 event,否則 event 會轉發給其他編輯器類。
# 阻止 InputEvent 到達其他編輯類。
func _forward_canvas_gui_input(event):
return true
// 阻止 InputEvent 到達其他編輯類。
public override bool ForwardCanvasGuiInput(InputEvent @event)
{
return true;
}
該方法回傳 false 才能將 InputEvent 轉發到其他編輯器類。
# 消耗 InputEventMouseMotion 並轉發其他 InputEvent 型別。
func _forward_canvas_gui_input(event):
if (event is InputEventMouseMotion):
return true
return false
// 消耗 InputEventMouseMotion 並轉發其他 InputEvent 型別。
public override bool _ForwardCanvasGuiInput(InputEvent @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 🔗
已棄用: Use EditorDock.dock_icon of a main screen dock.
在你的外掛中覆寫此方法並回傳一個 Texture2D(2D紋理),就可以為你的外掛設定一個圖示。
對於主螢幕外掛(Main Screen Plugins)來說,這個圖示會顯示在螢幕頂部的工具列上,位於“2D”、“3D”、“腳本”、“遊戲”和“素材商店”這些按鈕的右側。
理想情況下,外掛圖示應該是帶有透明背景的白色圖案,且尺寸為 16×16 像素。
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")
public override Texture2D _GetPluginIcon()
{
// You can use a custom icon:
return ResourceLoader.Load<Texture2D>("res://addons/my_plugin/my_plugin_icon.svg");
// Or use a built-in icon:
return EditorInterface.Singleton.GetEditorTheme().GetIcon("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.
Note: Main screen plugins should instead use EditorDock.title of a main screen dock.
Dictionary _get_state() virtual const 🔗
覆蓋該方法,以提供要儲存的狀態資料,如檢視位置、網格設定、折疊等。這可用於儲存場景(再次打開時,保持狀態)和切換分頁( 分頁回傳時,可以恢復狀態)。每個場景的資料會自動被儲存在編輯器中繼資料資料夾中的 editstate 檔案中。如果想為外掛儲存全域的(獨立於場景的)編輯器資料,可以改用 _get_window_layout()。
使用 _set_state() 恢復儲存的狀態。
注意:此方法不應該用於儲存應隨專案保留的重要設定。
注意:必須實作 _get_plugin_name(),才能正確儲存和恢復狀態。
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 🔗
如果外掛會編輯特定型別的物件(資源或節點),則請實作該函式。如果回傳 true,則將在編輯器請求時,呼叫函式 _edit() 和 _make_visible()。如果已經聲明瞭方法 _forward_canvas_gui_input() 和 _forward_3d_gui_input(),則它們也會被呼叫。
注意:每個外掛一次只應處理一種型別的物件。如果一個外掛處理多種型別的物件並且同時編輯這些物件,則會導致錯誤。
bool _has_main_screen() virtual const 🔗
已棄用: Use add_dock() instead, with EditorDock.default_slot set to EditorDock.DOCK_SLOT_MAIN_SCREEN.
Return true if this is a main screen editor plugin (it goes in the workspace selector together with 2D, 3D, Script, Game, and Asset Store).
You can add a main screen dock by using EditorDock with EditorDock.DOCK_LAYOUT_MAIN_SCREEN as available layout.
void _make_visible(visible: bool) virtual 🔗
當編輯器被要求變為可見時,該函式將被呼叫。它用於編輯特定物件型別的外掛程式。
請記住,你必須手動管理所有編輯器控制項的可見性。
PackedStringArray _run_scene(scene: String, args: PackedStringArray) virtual const 🔗
當編輯器中即將播放某個場景時,將呼叫該函式。args 是將被傳遞給新的 Godot 實例的命令行參數清單,該清單將被該函式回傳的清單替換。
func _run_scene(scene, args):
args.append("--an-extra-argument")
return args
注意:除非 EditorSettings.run/output/always_clear_output_on_play 為 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 新增到自動載入列表中。
將外掛新增至情境選單。slot 為新增外掛的情境選單。
注意:外掛的實例只能屬於單個情境選單槽。
Button add_control_to_bottom_panel(control: Control, title: String, shortcut: Shortcut = null) 🔗
已棄用: Use add_dock() instead, with EditorDock.default_slot set to EditorDock.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 the Alt modifier.
void add_control_to_container(container: CustomControlContainer, control: Control) 🔗
將自訂控制項新增到編輯器 UI 中的某個容器。
請記住,必須自己管理你的自訂控制項的可見性(並且很可能在新增後隱藏它)。
當外掛被停用時,請確保使用 remove_control_from_container() 移除自訂控制項,並使用 Node.queue_free() 將其釋放。
void add_control_to_dock(slot: DockSlot, control: Control, shortcut: Shortcut = null) 🔗
已棄用: Use add_dock() instead.
將控制項新增到特定的停靠面板槽位。
如果重新放置了停靠面板,並且只要該外掛處於活動狀態,編輯器就會在以後的會話中儲存停靠面板的位置。
停用外掛後,請確保使用 remove_control_from_docks() 移除自訂控制項,並使用 Node.queue_free() 將其釋放。
你還可以指定快捷鍵參數。按下該快捷鍵就會打開並聚焦該面板。
void add_custom_type(type: String, base: String, script: Script, icon: Texture2D) 🔗
新增一個自訂型別,它將出現在節點或資源的清單中。
選擇給定的節點或資源時,將實例化基本型別(例如“Node3D”、“Control”、“Resource”),然後腳本將被載入並將其設定為該物件。
注意:基本型別是該型別的類層次繼承的基本引擎類,而不是任何自訂型別的父類別。
可以使用虛方法 _handles() 通過檢查腳本或使用 is 關鍵字來檢查你的自訂物件是否正在被編輯。
在執行時,這將是一個帶有腳本的簡單物件,因此不需要呼叫該函式。
注意:以這種方式新增的自訂型別不是真正的類。它們只是使用特定腳本建立節點的助手。
void add_debugger_plugin(script: EditorDebuggerPlugin) 🔗
將一個 Script 作為除錯器外掛程式新增到除錯器。該腳本必須擴充 EditorDebuggerPlugin。
void add_dock(dock: EditorDock) 🔗
新增一個新的停靠面板。
當外掛停用時,請務必使用 remove_dock() 移除自訂停靠面板,並使用 Node.queue_free() 將其釋放。
void add_export_platform(platform: EditorExportPlatform) 🔗
注冊新的 EditorExportPlatform。匯出平台提供匯出到該平台的功能。
void add_export_plugin(plugin: EditorExportPlugin) 🔗
註冊一個新的 EditorExportPlugin。匯出外掛程式是用來在專案被匯出時執行工作的。
有關如何註冊外掛程式的範例,請參見 add_inspector_plugin()。
void add_import_plugin(importer: EditorImportPlugin, first_priority: bool = false) 🔗
註冊一個新的 EditorImportPlugin。匯入外掛程式用於將自訂的和不受支援的素材,作為一種自訂 Resource 型別匯入。
如果 first_priority 是 true,則該新的匯入外掛程式被首先插入列表中,並優先於預先存在的外掛程式。
注意:如果要匯入自訂 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_priority 為 true,則這個新的匯入外掛程式會被插入到列表的首位,優先於預先存在的外掛程式。
void add_scene_post_import_plugin(scene_import_plugin: EditorScenePostImportPlugin, first_priority: bool = false) 🔗
新增 EditorScenePostImportPlugin。這些外掛能夠在匯入對話框中新增新的選項,自訂 3D 素材的匯入過程。
如果 first_priority 為 true,則這個新的匯入外掛會被插入到清單的首位,優先於預先存在的外掛。
在專案 > 工具中新增名為 name 的自訂功能表專案。點選時會呼叫所提供的 callable。
在專案 > 工具中新增名為 name 的自訂 PopupMenu 子選單。請在清理外掛時呼叫 remove_tool_menu_item() 移除該選單。
void add_translation_parser_plugin(parser: EditorTranslationParserPlugin) 🔗
註冊一個自訂翻譯解析器外掛程式,用於從自訂檔中提取可翻譯的字串。
void add_undo_redo_inspector_hook_callback(callable: Callable) 🔗
掛鉤一個回呼函式到當屬性在屬性檢視器中被修改時的復原/重做動作建立過程。這允許例如儲存當指定的屬性被修改時可能會遺失的其他屬性。
該回呼函式應該有 4 個引數:Object undo_redo、Object modified_object、String property 以及 Variant new_value。它們分別是屬性檢視器使用的 UndoRedo 物件、目前被修改的物件、被修改屬性的名稱,以及該屬性即將採用的新值。
EditorInterface get_editor_interface() 🔗
已棄用: EditorInterface is a global singleton and can be accessed directly by its name.
回傳 EditorInterface 單例實例。
返回場景 > 另存為...下的 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_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) 🔗
從可用停靠面板中移除 dock。你需要手動呼叫 Node.queue_free() 來釋放它。
void remove_export_platform(platform: EditorExportPlatform) 🔗
移除由 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。
從專案 > 工具中移除名為 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.
設定停靠面板插槽中給定控制項的分頁圖示。設定為 null 會移除該圖示。
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() 中接收輸入,請使用該方法。如果外掛程式想要在場景中使用射線投射,它可能特別有用。
更新 2D 和 3D 編輯器視埠的疊加層。會導致方法 _forward_canvas_draw_over_viewport()、_forward_canvas_force_draw_over_viewport()、_forward_3d_draw_over_viewport() 和 _forward_3d_force_draw_over_viewport() 被呼叫。