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.

EditorExportPlugin

繼承: RefCounted < Object

在匯出專案時執行的腳本。

說明

EditorExportPlugins are automatically invoked whenever the user exports the project. They can be used to modify scenes and resources during project export based on what Feature Tags are set. For each plugin, _export_begin() is called at the beginning of the export process and then _export_file() is called for each exported file.

Register a EditorExportPlugin by creating a new EditorPlugin and calling its EditorPlugin.add_export_plugin() method.

教學

方法

bool

_begin_customize_resources(platform: EditorExportPlatform, features: PackedStringArray) virtual const

bool

_begin_customize_scenes(platform: EditorExportPlatform, features: PackedStringArray) virtual const

Resource

_customize_resource(resource: Resource, path: String) virtual required

Node

_customize_scene(scene: Node, path: String) virtual required

void

_end_customize_resources() virtual

void

_end_customize_scenes() virtual

void

_end_generate_apple_embedded_project(path: String, will_build_archive: bool) virtual

void

_export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int) virtual

void

_export_end() virtual

void

_export_file(path: String, type: String, features: PackedStringArray) virtual

PackedStringArray

_get_android_dependencies(platform: EditorExportPlatform, debug: bool) virtual const

PackedStringArray

_get_android_dependencies_maven_repos(platform: EditorExportPlatform, debug: bool) virtual const

PackedStringArray

_get_android_libraries(platform: EditorExportPlatform, debug: bool) virtual const

String

_get_android_manifest_activity_element_contents(platform: EditorExportPlatform, debug: bool) virtual const

String

_get_android_manifest_application_element_contents(platform: EditorExportPlatform, debug: bool) virtual const

String

_get_android_manifest_element_contents(platform: EditorExportPlatform, debug: bool) virtual const

int

_get_customization_configuration_hash() virtual required const

PackedStringArray

_get_export_features(platform: EditorExportPlatform, debug: bool) virtual const

bool

_get_export_option_visibility(platform: EditorExportPlatform, option: String) virtual const

String

_get_export_option_warning(platform: EditorExportPlatform, option: String) virtual const

Array[Dictionary]

_get_export_options(platform: EditorExportPlatform) virtual const

Dictionary

_get_export_options_overrides(platform: EditorExportPlatform) virtual const

String

_get_name() virtual required const

bool

_should_update_export_options(platform: EditorExportPlatform) virtual const

bool

_supports_platform(platform: EditorExportPlatform) virtual const

PackedByteArray

_update_android_prebuilt_manifest(platform: EditorExportPlatform, manifest_data: PackedByteArray) virtual const

void

add_apple_embedded_platform_bundle_file(path: String)

void

add_apple_embedded_platform_cpp_code(code: String)

void

add_apple_embedded_platform_embedded_framework(path: String)

void

add_apple_embedded_platform_framework(path: String)

void

add_apple_embedded_platform_linker_flags(flags: String)

void

add_apple_embedded_platform_plist_content(plist_content: String)

void

add_apple_embedded_platform_project_static_lib(path: String)

void

add_file(path: String, file: PackedByteArray, remap: bool)

void

add_ios_bundle_file(path: String)

void

add_ios_cpp_code(code: String)

void

add_ios_embedded_framework(path: String)

void

add_ios_framework(path: String)

void

add_ios_linker_flags(flags: String)

void

add_ios_plist_content(plist_content: String)

void

add_ios_project_static_lib(path: String)

void

add_macos_plugin_file(path: String)

void

add_shared_object(path: String, tags: PackedStringArray, target: String)

EditorExportPlatform

get_export_platform() const

EditorExportPreset

get_export_preset() const

Variant

get_option(name: StringName) const

void

skip()


方法說明

bool _begin_customize_resources(platform: EditorExportPlatform, features: PackedStringArray) virtual const 🔗

Return true if this plugin will customize resources based on the platform and features used.

When enabled, _get_customization_configuration_hash() and _customize_resource() will be called and must be implemented.


bool _begin_customize_scenes(platform: EditorExportPlatform, features: PackedStringArray) virtual const 🔗

Return true if this plugin will customize scenes based on the platform and features used.

When enabled, _get_customization_configuration_hash() and _customize_scene() will be called and must be implemented.

Note: _customize_scene() will only be called for scenes that have been modified since the last export.


Resource _customize_resource(resource: Resource, path: String) virtual required 🔗

Customize a resource. If changes are made to it, return the same or a new resource. Otherwise, return null. When a new resource is returned, resource will be replaced by a copy of the new resource.

The path argument is only used when customizing an actual file, otherwise this means that this resource is part of another one and it will be empty.

Implementing this method is required if _begin_customize_resources() returns true.

Note: When customizing any of the following types and returning another resource, the other resource should not be skipped using skip() in _export_file():


Node _customize_scene(scene: Node, path: String) virtual required 🔗

Customize a scene. If changes are made to it, return the same or a new scene. Otherwise, return null. If a new scene is returned, it is up to you to dispose of the old one.

Implementing this method is required if _begin_customize_scenes() returns true.

Note: To change a variable in your scene, use the @export annotation when declaring it.


void _end_customize_resources() virtual 🔗

資源的自訂處理完成時呼叫。


void _end_customize_scenes() virtual 🔗

場景的自訂處理完成時呼叫。


void _end_generate_apple_embedded_project(path: String, will_build_archive: bool) virtual 🔗

This is called after Xcode project generation, but before it is built.

Note: Only supported on iOS and visionOS.


void _export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int) virtual 🔗

由使用者重寫的虛方法。它在匯出開始時呼叫,並提供有關匯出的所有資訊。features 是匯出的功能列表,is_debugtrue 時用於除錯建構,path 是匯出專案的目標路徑。flags 僅在運作可運作設定檔時使用,例如在 Android 上使用本機運作時。


void _export_end() virtual 🔗

可以被使用者重寫的虛方法。在匯出完成後被呼叫。


void _export_file(path: String, type: String, features: PackedStringArray) virtual 🔗

Virtual method to be overridden by the user. Called for each exported file before _customize_resource() and _customize_scene(). The arguments can be used to identify the file. path is the path of the file, type is the Resource represented by the file (e.g. PackedScene), and features is the list of features for the export.

Calling skip() inside this callback will make the file not included in the export.


PackedStringArray _get_android_dependencies(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。呼叫此方法是為了檢索此插件提供的Android 依賴項集。每個傳回的Android 依賴項應具有Android 遠端二進位依賴項的格式: org.godot.example:my-plugin:0.0.0

有關更多信息,請參閱 有關依賴項的 Android 文件

注意: 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


PackedStringArray _get_android_dependencies_maven_repos(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。呼叫此方法是為了檢索此插件提供的 Android 依賴項集的 Maven 儲存庫的 URL。

有關更多信息,請參閱 有關依賴管理的 Gradle 檔案

注意: Google 的 Maven 儲存庫和 Maven Central 儲存庫已預設包含在內。

注意: 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


PackedStringArray _get_android_libraries(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。呼叫此方法是為了檢索此外掛程式提供的 Android 庫存檔 (AAR) 檔案的本機路徑。

注意:相對路徑必須相對於Godot的res://addons/目錄。例如,位於 res://addons/hello_world_plugin/HelloWorld.release.aar 下的 AAR 檔案可以使用 res://addons/hello_world_plugin/HelloWorld.release 作為絕對路徑返回.aar 或使用hello_world_plugin/HelloWorld.release.aar 的相對路徑。

** 注意:** 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


String _get_android_manifest_activity_element_contents(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。這在匯出時用於更新生成的 Android 列表中的 activity 元素的內容。

注意: 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


String _get_android_manifest_application_element_contents(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。這在匯出時用於更新生成的 Android 列表中的 application 元素的內容。

注意: 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


String _get_android_manifest_element_contents(platform: EditorExportPlatform, debug: bool) virtual const 🔗

由使用者重寫的虛擬方法。這在匯出時用於更新生成的 Android 列表中的 manifest 元素的內容。

注意: 僅在 Android 上受支援,並且需要啟用 EditorExportPlatformAndroid.gradle_build/use_gradle_build


int _get_customization_configuration_hash() virtual required const 🔗

Return a hash based on the configuration passed (for both scenes and resources). This helps keep separate caches for separate export configurations.

Implementing this method is required if _begin_customize_resources() returns true.

Note: _customize_resource() and _customize_scene() will not be called when the EditorExportPlugin script is modified unless this hash changes too.


PackedStringArray _get_export_features(platform: EditorExportPlatform, debug: bool) virtual const 🔗

返回該預設對於給定的 platform,應該具有的附加功能的 PackedStringArray


bool _get_export_option_visibility(platform: EditorExportPlatform, option: String) virtual const 🔗

Validates option and returns the visibility for the specified platform. The default implementation returns true for all options.


String _get_export_option_warning(platform: EditorExportPlatform, option: String) virtual const 🔗

檢查給定 option 的要求,如果不滿足則傳回非空警告字串。

注意: 使用 get_option() 檢查匯出選項的值。


Array[Dictionary] _get_export_options(platform: EditorExportPlatform) virtual const 🔗

返回匯出選項列表,能夠用來配置這個匯出外掛程式。

返回值中的每個元素都是一個 Dictionary,包含如下欄位:

  • option:字典,結構與 Object.get_property_list() 文件中的相同,但所有欄位都是可選的。

  • default_value:該選項的預設值。

  • update_visibility:可選的布林值。如果設為 true,則該選項發生變化時,預設會發出 Object.property_list_changed


Dictionary _get_export_options_overrides(platform: EditorExportPlatform) virtual const 🔗

Return a Dictionary of override values for export options, that will be used instead of user-provided values. Overridden options will be hidden from the user interface.

class MyExportPlugin extends EditorExportPlugin:
    func _get_name() -> String:
        return "MyExportPlugin"

    func _supports_platform(platform) -> bool:
        if platform is EditorExportPlatformPC:
            # Run on all desktop platforms including Windows, MacOS and Linux.
            return true
        return false

    func _get_export_options_overrides(platform) -> Dictionary:
        # Override "Embed PCK" to always be enabled.
        return {
            "binary_format/embed_pck": true,
        }

String _get_name() virtual required const 🔗

返回該外掛程式的名稱識別字(供匯出器將來識別)。外掛程式在匯出前按名稱排序。

需要實作該方法。


bool _should_update_export_options(platform: EditorExportPlatform) virtual const 🔗

Return true if the result of _get_export_options() has changed and the export options of the preset corresponding to platform should be updated.


bool _supports_platform(platform: EditorExportPlatform) virtual const 🔗

Return true if the plugin supports the given platform.


PackedByteArray _update_android_prebuilt_manifest(platform: EditorExportPlatform, manifest_data: PackedByteArray) virtual const 🔗

Provide access to the Android prebuilt manifest and allows the plugin to modify it if needed.

Implementers of this virtual method should take the binary manifest data from manifest_data, copy it, modify it, and then return it with the modifications.

If no modifications are needed, then an empty PackedByteArray should be returned.


void add_apple_embedded_platform_bundle_file(path: String) 🔗

Adds an Apple embedded platform bundle file from the given path to the exported project.


void add_apple_embedded_platform_cpp_code(code: String) 🔗

Adds C++ code to the Apple embedded platform export. The final code is created from the code appended by each active export plugin.


void add_apple_embedded_platform_embedded_framework(path: String) 🔗

Adds a dynamic library (*.dylib, *.framework) to the Linking Phase in the Apple embedded platform's Xcode project and embeds it into the resulting binary.

Note: For static libraries (*.a), this works in the same way as add_apple_embedded_platform_framework().

Note: This method should not be used for System libraries as they are already present on the device.


void add_apple_embedded_platform_framework(path: String) 🔗

Adds a static library (*.a) or a dynamic library (*.dylib, *.framework) to the Linking Phase to the Apple embedded platform's Xcode project.


void add_apple_embedded_platform_linker_flags(flags: String) 🔗

Adds linker flags for the Apple embedded platform export.


void add_apple_embedded_platform_plist_content(plist_content: String) 🔗

Adds additional fields to the Apple embedded platform's project Info.plist file.


void add_apple_embedded_platform_project_static_lib(path: String) 🔗

Adds a static library from the given path to the Apple embedded platform project.


void add_file(path: String, file: PackedByteArray, remap: bool) 🔗

Adds a custom file to be exported. path is the virtual path that can be used to load the file, file is the binary data of the file.

When called inside _export_file() and remap is true, the current file will not be exported, but instead remapped to this custom file. remap is ignored when called in other places.

file will not be imported, so consider using _customize_resource() to remap imported resources.


void add_ios_bundle_file(path: String) 🔗

已棄用: Use add_apple_embedded_platform_bundle_file() instead.

將給定的path中的iOS bundle檔新增到匯出的專案中。


void add_ios_cpp_code(code: String) 🔗

已棄用: Use add_apple_embedded_platform_cpp_code() instead.

Adds C++ code to the iOS export. The final code is created from the code appended by each active export plugin.


void add_ios_embedded_framework(path: String) 🔗

已棄用: Use add_apple_embedded_platform_embedded_framework() instead.

Adds a dynamic library (*.dylib, *.framework) to Linking Phase in iOS's Xcode project and embeds it into resulting binary.

Note: For static libraries (*.a), this works the in same way as add_apple_embedded_platform_framework().

Note: This method should not be used for System libraries as they are already present on the device.


void add_ios_framework(path: String) 🔗

已棄用: Use add_apple_embedded_platform_framework() instead.

Adds a static library (*.a) or a dynamic library (*.dylib, *.framework) to the Linking Phase to the iOS Xcode project.


void add_ios_linker_flags(flags: String) 🔗

已棄用: Use add_apple_embedded_platform_linker_flags() instead.

為 iOS 匯出新增連結器旗標。


void add_ios_plist_content(plist_content: String) 🔗

已棄用: Use add_apple_embedded_platform_plist_content() instead.

Adds additional fields to the iOS project Info.plist file.


void add_ios_project_static_lib(path: String) 🔗

已棄用: Use add_apple_embedded_platform_project_static_lib() instead.

Adds a static library from the given path to the iOS project.


void add_macos_plugin_file(path: String) 🔗

將配對 path 的檔或目錄,新增到 macOS 套用套裝程式的 PlugIns 目錄中。

注意:僅適用於 macOS 匯出。


void add_shared_object(path: String, tags: PackedStringArray, target: String) 🔗

新增一個共用物件或僅包含具有給定 tags 和目標 path 的共用物件的目錄。

注意:使用 macOS 匯出時,這些共用物件將被新增到套用套裝程式的 Frameworks 目錄中。

如果使用的是目錄,如果將非程式碼物件放在該目錄中,則程式碼簽章時會報告有錯。


EditorExportPlatform get_export_platform() const 🔗

Returns currently used export platform.


EditorExportPreset get_export_preset() const 🔗

Returns currently used export preset.


Variant get_option(name: StringName) const 🔗

返回 _get_export_options() 提供的匯出選項的目前值。


void skip() 🔗

To be called inside _export_file(). Skips the current file, so it's not included in the export.