Skip to content

Commit

Permalink
Respect "compress_binary_resources" editor setting
Browse files Browse the repository at this point in the history
  • Loading branch information
gelvinp committed Jun 18, 2023
1 parent 9f12e7b commit 9408ac0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions editor/import/resource_importer_scene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "core/error/error_macros.h"
#include "core/io/resource_saver.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/import/scene_import_settings.h"
#include "scene/3d/area_3d.h"
#include "scene/3d/collision_shape_3d.h"
Expand Down Expand Up @@ -2528,6 +2529,11 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p

progress.step(TTR("Saving..."), 104);

int flags = 0;
if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
flags |= ResourceSaver::FLAG_COMPRESS;
}

if (animation_importer) {
Ref<AnimationLibrary> library;
for (int i = 0; i < scene->get_child_count(); i++) {
Expand All @@ -2546,15 +2552,15 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
library.instantiate(); // Will be empty
}

print_verbose("Saving animation to: " + p_save_path + ".scn");
err = ResourceSaver::save(library, p_save_path + ".res"); //do not take over, let the changed files reload themselves
print_verbose("Saving animation to: " + p_save_path + ".res");
err = ResourceSaver::save(library, p_save_path + ".res", flags); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save animation to file '" + p_save_path + ".res'.");

} else {
Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene);
print_verbose("Saving scene to: " + p_save_path + ".scn");
err = ResourceSaver::save(packer, p_save_path + ".scn"); //do not take over, let the changed files reload themselves
err = ResourceSaver::save(packer, p_save_path + ".scn", flags); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V_MSG(err != OK, err, "Cannot save scene to file '" + p_save_path + ".scn'.");
}

Expand Down

0 comments on commit 9408ac0

Please sign in to comment.