diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml
index 853348f64ce5..436f471e5d36 100644
--- a/doc/classes/EditorExportPlugin.xml
+++ b/doc/classes/EditorExportPlugin.xml
@@ -178,6 +178,30 @@
- [code]update_visibility[/code]: An optional boolean value. If set to [code]true[/code], the preset will emit [signal Object.property_list_changed] when the option is changed.
+
+
+
+
+ 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.
+ [codeblock]
+ 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,
+ }
+ [/codeblock]
+
+
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 6ec656d588d7..4cc2ff6ad2f0 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -955,6 +955,7 @@ void EditorNode::_fs_changed() {
err = FAILED;
export_error = vformat("Export preset \"%s\" doesn't have a matching platform.", preset_name);
} else {
+ export_preset->update_value_overrides();
if (export_defer.pack_only) { // Only export .pck or .zip data pack.
if (export_path.ends_with(".zip")) {
err = platform->export_zip(export_preset, export_defer.debug, export_path);
diff --git a/editor/export/editor_export_plugin.cpp b/editor/export/editor_export_plugin.cpp
index ec8c8c7b69a8..5353eae6545b 100644
--- a/editor/export/editor_export_plugin.cpp
+++ b/editor/export/editor_export_plugin.cpp
@@ -285,6 +285,12 @@ String EditorExportPlugin::_get_export_option_warning(const Ref &p_platform) const {
+ Dictionary ret;
+ GDVIRTUAL_CALL(_get_export_options_overrides, p_platform, ret);
+ return ret;
+}
+
void EditorExportPlugin::_export_file(const String &p_path, const String &p_type, const HashSet &p_features) {
}
@@ -327,6 +333,7 @@ void EditorExportPlugin::_bind_methods() {
GDVIRTUAL_BIND(_end_customize_resources);
GDVIRTUAL_BIND(_get_export_options, "platform");
+ GDVIRTUAL_BIND(_get_export_options_overrides, "platform");
GDVIRTUAL_BIND(_should_update_export_options, "platform");
GDVIRTUAL_BIND(_get_export_option_warning, "platform", "option");
diff --git a/editor/export/editor_export_plugin.h b/editor/export/editor_export_plugin.h
index fe97d2e04f4b..a4e9917a81cb 100644
--- a/editor/export/editor_export_plugin.h
+++ b/editor/export/editor_export_plugin.h
@@ -128,6 +128,7 @@ class EditorExportPlugin : public RefCounted {
GDVIRTUAL2RC(PackedStringArray, _get_export_features, const Ref &, bool);
GDVIRTUAL1RC(TypedArray, _get_export_options, const Ref &);
+ GDVIRTUAL1RC(Dictionary, _get_export_options_overrides, const Ref &);
GDVIRTUAL1RC(bool, _should_update_export_options, const Ref &);
GDVIRTUAL2RC(String, _get_export_option_warning, const Ref &, String);
@@ -155,6 +156,7 @@ class EditorExportPlugin : public RefCounted {
virtual PackedStringArray _get_export_features(const Ref &p_export_platform, bool p_debug) const;
virtual void _get_export_options(const Ref &p_export_platform, List *r_options) const;
+ virtual Dictionary _get_export_options_overrides(const Ref &p_export_platform) const;
virtual bool _should_update_export_options(const Ref &p_export_platform) const;
virtual String _get_export_option_warning(const Ref &p_export_platform, const String &p_option_name) const;
diff --git a/editor/export/editor_export_preset.cpp b/editor/export/editor_export_preset.cpp
index 478ef980374a..8c3b6693e392 100644
--- a/editor/export/editor_export_preset.cpp
+++ b/editor/export/editor_export_preset.cpp
@@ -37,6 +37,7 @@ bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value)
EditorExport::singleton->save_presets();
if (update_visibility.has(p_name)) {
if (update_visibility[p_name]) {
+ update_value_overrides();
notify_property_list_changed();
}
return true;
@@ -46,6 +47,11 @@ bool EditorExportPreset::_set(const StringName &p_name, const Variant &p_value)
}
bool EditorExportPreset::_get(const StringName &p_name, Variant &r_ret) const {
+ if (value_overrides.has(p_name)) {
+ r_ret = value_overrides[p_name];
+ return true;
+ }
+
if (values.has(p_name)) {
r_ret = values[p_name];
return true;
@@ -59,6 +65,10 @@ void EditorExportPreset::_bind_methods() {
}
String EditorExportPreset::_get_property_warning(const StringName &p_name) const {
+ if (value_overrides.has(p_name)) {
+ return String();
+ }
+
String warning = platform->get_export_option_warning(this, p_name);
if (!warning.is_empty()) {
warning += "\n";
@@ -83,7 +93,7 @@ String EditorExportPreset::_get_property_warning(const StringName &p_name) const
void EditorExportPreset::_get_property_list(List *p_list) const {
for (const KeyValue &E : properties) {
- if (platform->get_export_option_visibility(this, E.key)) {
+ if (!value_overrides.has(E.key) && platform->get_export_option_visibility(this, E.key)) {
p_list->push_back(E.value);
}
}
@@ -119,6 +129,37 @@ void EditorExportPreset::update_files() {
}
}
+void EditorExportPreset::update_value_overrides() {
+ Vector[> export_plugins = EditorExport::get_singleton()->get_export_plugins();
+ HashMap new_value_overrides;
+
+ value_overrides.clear();
+
+ for (int i = 0; i < export_plugins.size(); i++) {
+ if (!export_plugins[i]->supports_platform(platform)) {
+ continue;
+ }
+
+ export_plugins.write[i]->set_export_preset(Ref(this));
+
+ Dictionary plugin_overrides = export_plugins[i]->_get_export_options_overrides(platform);
+ if (!plugin_overrides.is_empty()) {
+ Array keys = plugin_overrides.keys();
+ for (int x = 0; x < keys.size(); x++) {
+ StringName key = keys[x];
+ Variant value = plugin_overrides[key];
+ if (new_value_overrides.has(key) && new_value_overrides[key] != value) {
+ WARN_PRINT_ED(vformat("Editor export plugin '%s' overrides pre-existing export option override '%s' with new value.", export_plugins[i]->get_name(), key));
+ }
+ new_value_overrides[key] = value;
+ }
+ }
+ }
+
+ value_overrides = new_value_overrides;
+ notify_property_list_changed();
+}
+
Vector EditorExportPreset::get_files_to_export() const {
Vector files;
for (const String &E : selected_files) {
diff --git a/editor/export/editor_export_preset.h b/editor/export/editor_export_preset.h
index effce48111aa..03ff75b4677e 100644
--- a/editor/export/editor_export_preset.h
+++ b/editor/export/editor_export_preset.h
@@ -78,6 +78,7 @@ class EditorExportPreset : public RefCounted {
HashMap properties;
HashMap values;
+ HashMap value_overrides;
HashMap update_visibility;
String name;
@@ -107,6 +108,7 @@ class EditorExportPreset : public RefCounted {
bool has(const StringName &p_property) const { return values.has(p_property); }
void update_files();
+ void update_value_overrides();
Vector get_files_to_export() const;
Dictionary get_customized_files() const;
diff --git a/editor/export/project_export.cpp b/editor/export/project_export.cpp
index ff1fa3470e27..4a066b3d3e2e 100644
--- a/editor/export/project_export.cpp
+++ b/editor/export/project_export.cpp
@@ -276,6 +276,9 @@ void ProjectExportDialog::_edit_preset(int p_index) {
export_path->update_property();
runnable->set_disabled(false);
runnable->set_pressed(current->is_runnable());
+ if (parameters->get_edited_object() != current.ptr()) {
+ current->update_value_overrides();
+ }
parameters->set_object_class(current->get_platform()->get_class_name());
parameters->edit(current.ptr());
@@ -1100,6 +1103,7 @@ void ProjectExportDialog::_export_project_to_path(const String &p_path) {
exporting = true;
platform->clear_messages();
+ current->update_value_overrides();
Error err = platform->export_project(current, export_debug->is_pressed(), current->get_export_path(), 0);
result_dialog_log->clear();
if (err != ERR_SKIP) {
@@ -1149,6 +1153,7 @@ void ProjectExportDialog::_export_all(bool p_debug) {
ep.step(preset->get_name(), i);
platform->clear_messages();
+ preset->update_value_overrides();
Error err = platform->export_project(preset, p_debug, preset->get_export_path(), 0);
if (err == ERR_SKIP) {
exporting = false;
]