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

Inherits: RefCounted < Object

A script that is executed when exporting the project.

描述

EditorExportPlugins are automatically invoked whenever the user exports the project. Their most common use is to determine what files are being included in the exported project. For each plugin, _export_begin is called at the beginning of the export process and then _export_file is called for each exported file.

To use EditorExportPlugin, register it using the EditorPlugin.add_export_plugin method first.

教程

Methods

bool

_begin_customize_resources ( EditorExportPlatform platform, PackedStringArray features ) virtual const

bool

_begin_customize_scenes ( EditorExportPlatform platform, PackedStringArray features ) virtual const

Resource

_customize_resource ( Resource resource, String path ) virtual

Node

_customize_scene ( Node scene, String path ) virtual

void

_end_customize_resources ( ) virtual

void

_end_customize_scenes ( ) virtual

void

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

void

_export_end ( ) virtual

void

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

PackedStringArray

_get_android_dependencies ( EditorExportPlatform platform, bool debug ) virtual const

PackedStringArray

_get_android_dependencies_maven_repos ( EditorExportPlatform platform, bool debug ) virtual const

PackedStringArray

_get_android_libraries ( EditorExportPlatform platform, bool debug ) virtual const

String

_get_android_manifest_activity_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

String

_get_android_manifest_application_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

String

_get_android_manifest_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

int

_get_customization_configuration_hash ( ) virtual const

PackedStringArray

_get_export_features ( EditorExportPlatform platform, bool debug ) virtual const

String

_get_export_option_warning ( EditorExportPlatform platform, String option ) virtual const

Dictionary[]

_get_export_options ( EditorExportPlatform platform ) virtual const

String

_get_name ( ) virtual const

bool

_should_update_export_options ( EditorExportPlatform platform ) virtual const

bool

_supports_platform ( EditorExportPlatform platform ) virtual const

void

add_file ( String path, PackedByteArray file, bool remap )

void

add_ios_bundle_file ( String path )

void

add_ios_cpp_code ( String code )

void

add_ios_embedded_framework ( String path )

void

add_ios_framework ( String path )

void

add_ios_linker_flags ( String flags )

void

add_ios_plist_content ( String plist_content )

void

add_ios_project_static_lib ( String path )

void

add_macos_plugin_file ( String path )

void

add_shared_object ( String path, PackedStringArray tags, String target )

Variant

get_option ( StringName name ) const

void

skip ( )


Method Descriptions

bool _begin_customize_resources ( EditorExportPlatform platform, PackedStringArray features ) virtual const

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

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


bool _begin_customize_scenes ( EditorExportPlatform platform, PackedStringArray features ) virtual const

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


Resource _customize_resource ( Resource resource, String path ) virtual

Customize a resource. If changes are made to it, return the same or a new resource. Otherwise, return null.

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.


Node _customize_scene ( Node scene, String path ) virtual

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.


void _end_customize_resources ( ) virtual

This is called when the customization process for resources ends.


void _end_customize_scenes ( ) virtual

This is called when the customization process for scenes ends.


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

Virtual method to be overridden by the user. It is called when the export starts and provides all information about the export. features is the list of features for the export, is_debug is true for debug builds, path is the target path for the exported project. flags is only used when running a runnable profile, e.g. when using native run on Android.


void _export_end ( ) virtual

Virtual method to be overridden by the user. Called when the export is finished.


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

Virtual method to be overridden by the user. Called for each exported file, providing arguments that 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 ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is called to retrieve the set of Android dependencies provided by this plugin. Each returned Android dependency should have the format of an Android remote binary dependency: org.godot.example:my-plugin:0.0.0

For more information see Android documentation on dependencies.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


PackedStringArray _get_android_dependencies_maven_repos ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is called to retrieve the URLs of Maven repositories for the set of Android dependencies provided by this plugin.

For more information see Gradle documentation on dependency management.

Note: Google's Maven repo and the Maven Central repo are already included by default.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


PackedStringArray _get_android_libraries ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is called to retrieve the local paths of the Android libraries archive (AAR) files provided by this plugin.

Note: Relative paths must be relative to Godot's res://addons/ directory. For example, an AAR file located under res://addons/hello_world_plugin/HelloWorld.release.aar can be returned as an absolute path using res://addons/hello_world_plugin/HelloWorld.release.aar or a relative path using hello_world_plugin/HelloWorld.release.aar.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


String _get_android_manifest_activity_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is used at export time to update the contents of the activity element in the generated Android manifest.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


String _get_android_manifest_application_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is used at export time to update the contents of the application element in the generated Android manifest.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


String _get_android_manifest_element_contents ( EditorExportPlatform platform, bool debug ) virtual const

Virtual method to be overridden by the user. This is used at export time to update the contents of the manifest element in the generated Android manifest.

Note: Only supported on Android and requires EditorExportPlatformAndroid.gradle_build/use_gradle_build to be enabled.


int _get_customization_configuration_hash ( ) virtual 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.


PackedStringArray _get_export_features ( EditorExportPlatform platform, bool debug ) virtual const

Return a PackedStringArray of additional features this preset, for the given platform, should have.


String _get_export_option_warning ( EditorExportPlatform platform, String option ) virtual const

Check the requirements for the given option and return a non-empty warning string if they are not met.

Note: Use get_option to check the value of the export options.


Dictionary[] _get_export_options ( EditorExportPlatform platform ) virtual const

Return a list of export options that can be configured for this export plugin.

Each element in the return value is a Dictionary with the following keys:

  • option: A dictionary with the structure documented by Object.get_property_list, but all keys are optional.

  • default_value: The default value for this option.

  • update_visibility: An optional boolean value. If set to true, the preset will emit Object.property_list_changed when the option is changed.


String _get_name ( ) virtual const

Return the name identifier of this plugin (for future identification by the exporter). The plugins are sorted by name before exporting.

Implementing this method is required.


bool _should_update_export_options ( EditorExportPlatform platform ) virtual const

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


bool _supports_platform ( EditorExportPlatform platform ) virtual const

Return true if the plugin supports the given platform.


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

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.


void add_ios_bundle_file ( String path )

Adds an iOS bundle file from the given path to the exported project.


void add_ios_cpp_code ( String code )

Adds a 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 ( String path )

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) works in same way as add_ios_framework.

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


void add_ios_framework ( String path )

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


void add_ios_linker_flags ( String flags )

Adds linker flags for the iOS export.


void add_ios_plist_content ( String plist_content )

Adds content for iOS Property List files.


void add_ios_project_static_lib ( String path )

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


void add_macos_plugin_file ( String path )

Adds file or directory matching path to PlugIns directory of macOS app bundle.

Note: This is useful only for macOS exports.


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

Adds a shared object or a directory containing only shared objects with the given tags and destination path.

Note: In case of macOS exports, those shared objects will be added to Frameworks directory of app bundle.

In case of a directory code-sign will error if you place non code object in directory.


Variant get_option ( StringName name ) const

Returns the current value of an export option supplied by _get_export_options.


void skip ( )

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