summaryrefslogtreecommitdiff
path: root/editor/editor_export.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_export.cpp')
-rw-r--r--editor/editor_export.cpp31
1 files changed, 29 insertions, 2 deletions
diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp
index 3f618c3199..b330f5d177 100644
--- a/editor/editor_export.cpp
+++ b/editor/editor_export.cpp
@@ -39,10 +39,10 @@
#include "io/zip_io.h"
#include "os/file_access.h"
#include "project_settings.h"
+#include "scene/resources/scene_format_text.h"
#include "script_language.h"
-#include "version.h"
-
#include "thirdparty/misc/md5.h"
+#include "version.h"
static int _get_pad(int p_alignment, int p_n) {
@@ -1399,3 +1399,30 @@ EditorExportPlatformPC::EditorExportPlatformPC() {
chmod_flags = -1;
}
+
+///////////////////////
+
+void EditorExportTextSceneToBinaryPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
+
+ String extension = p_path.get_extension().to_lower();
+ if (extension != "tres" && extension != "tscn") {
+ return;
+ }
+
+ print_line("exporting " + p_path);
+
+ bool convert = GLOBAL_GET("editor/convert_text_resources_to_binary_on_export");
+ if (!convert)
+ return;
+ String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("file.res");
+ Error err = ResourceFormatLoaderText::convert_file_to_binary(p_path, tmp_path);
+ ERR_FAIL_COND(err != OK);
+ Vector<uint8_t> data = FileAccess::get_file_as_array(tmp_path);
+ ERR_FAIL_COND(data.size() == 0);
+ add_file(p_path + ".converted.res", data, true);
+}
+
+EditorExportTextSceneToBinaryPlugin::EditorExportTextSceneToBinaryPlugin() {
+
+ GLOBAL_DEF("editor/convert_text_resources_to_binary_on_export", false);
+}