Allow skipping imported resource files from export

This commit is contained in:
kobewi 2024-04-07 23:28:52 +02:00
parent e5b4ef8e95
commit 398892ccc0
2 changed files with 13 additions and 1 deletions

View File

@ -313,7 +313,7 @@
<method name="skip"> <method name="skip">
<return type="void" /> <return type="void" />
<description> <description>
To be called inside [method _export_file]. Skips the current file, so it's not included in the export. To be called inside [method _export_file], [method _customize_resource], or [method _customize_scene]. Skips the current file, so it's not included in the export.
</description> </description>
</method> </method>
</methods> </methods>

View File

@ -791,6 +791,10 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
if (!customize_scenes_plugins.is_empty()) { if (!customize_scenes_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) { for (Ref<EditorExportPlugin> &plugin : customize_scenes_plugins) {
Node *customized = plugin->_customize_scene(node, p_path); Node *customized = plugin->_customize_scene(node, p_path);
if (plugin->skipped) {
plugin->_clear();
return String();
}
if (customized != nullptr) { if (customized != nullptr) {
node = customized; node = customized;
modified = true; modified = true;
@ -824,6 +828,10 @@ String EditorExportPlatform::_export_customize(const String &p_path, LocalVector
if (!customize_resources_plugins.is_empty()) { if (!customize_resources_plugins.is_empty()) {
for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) { for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
Ref<Resource> new_res = plugin->_customize_resource(res, p_path); Ref<Resource> new_res = plugin->_customize_resource(res, p_path);
if (plugin->skipped) {
plugin->_clear();
return String();
}
if (new_res.is_valid()) { if (new_res.is_valid()) {
modified = true; modified = true;
if (new_res != res) { if (new_res != res) {
@ -1139,6 +1147,10 @@ Error EditorExportPlatform::export_project_files(bool p_main_pack, const Ref<Edi
// Before doing this, try to see if it can be customized. // Before doing this, try to see if it can be customized.
String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false); String export_path = _export_customize(path, customize_resources_plugins, customize_scenes_plugins, export_cache, export_base_path, false);
if (export_path.is_empty()) {
// Skipped from plugin.
continue;
}
if (export_path != path) { if (export_path != path) {
// It was actually customized. // It was actually customized.