[Found workaround] Pack external resources into .pck at runtime

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jean3219

Hey :slight_smile:

I want to pack external .obj files into a pck file, which I can use later. All at runtime… But when try to using the .obj file from the loaded .pck following error message comes:

Loading resource: res://Resources/Test-Track/Objects/untitled.obj
ERROR: _load: No loader found for resource: res://Resources/Test-Track/Objects/untitled.obj.
    At: core/io/resource_loader.cpp:290.

My code for packing an .obj file is only:

var packer = PCKPacker.new()
packer.add_file("res://Resources/" + resource_path, external_path_to_obj)

I think there’s missing something. Does anyone have an idea?
Everything should work at runtime…

Note about formatting: The Q&A platform does not support triple backticks. Instead, every line must be indented with 4 spaces. I edited your post to fix formatting.

Calinou | 2021-08-29 17:18

Thank you very much

Jean3219 | 2021-08-30 12:16

:bust_in_silhouette: Reply From: Jean3219

Did a workaround and wrote a new godot project with plugin:


jEssentials.copy_folder_recursively(editor_directory_path + "Resources", "res://Resources")
print("Finished copying files.")
# signal resources_imported:
# get_editor_interface().get_resource_filesystem().scan()

Exported .pck:

var files_to_export = []
files_to_export.append_array(jEssentials.crawl_directory_for("res://.import/", "stex"))
files_to_export.append_array(jEssentials.crawl_directory_for("res://.import/", "mesh"))
files_to_export.append_array(jEssentials.crawl_directory_for("res://Resources/", "import"))
files_to_export.append_array(jEssentials.crawl_directory_for("res://Resources/", "tres"))
files_to_export.append_array(jEssentials.crawl_directory_for("res://Resources/", "tscn"))

var packer = PCKPacker.new()
for file in files_to_export:
	packer.add_file(file, file)

jEssentials can be found here: GitHub - Jean28518/Godot-jTools: Useful toolset for creating games/plugins/etc. with Godot Engine