Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability for PackedScenes and GDScripts to have import files #98029

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wstumpfz
Copy link

@wstumpfz wstumpfz commented Oct 9, 2024

I added the ability for PackedScenes and GDScripts to have import files. To accomplish that I had to make two fundamental changes to Godot:

  1. Add the concept of "read only or not" to "resource assets" (resource assets = assets with import files). Previously Godot assumed any resource asset was read only. PackedScenes and GDScripts are not read only and can be edited/saved directly. In addition on export we want to use those assets directly not their corresponding files in the .godot folder (e.g. for a texture on export Godot wouldn't use the reference resource asset "someTexture.png" file but the corresponding encoded etc2/dxt/etc texture in the .godot folder. For packedscenes/gdscripts though we want to use the reference resource asset).

  2. When loading assets, use the "import order" on asset loaders to pick the right one instead of picking the first one Godot finds (see ResourceLoader::_load in resource_loader.cpp). We do this because by creating importers for PackedScenes and GDScripts, we are also creating loaders for those asset types. But PackedScenes and GDScripts already have native loaders, so we need to make sure those "native loaders" get picked over our "importing loaders". We do this by setting our importing loaders with a lower import order and changing ResourceLoader to use those orders when finding the right loader to choose.

This is "step one" in my effort to add "pack file tags" to facilitate exporting many pack files (godotengine/godot-proposals#10580). I tested this change with various godot projects and exporting to Windows/Android platforms.

importer_example
scene_import_file
gdscript_import_file

… in order to (later) add metadata to those assets. To accomplish that I added the concept of "non-read only" resources and a loader priority when loading those resources.
@fire
Copy link
Member

fire commented Oct 9, 2024

Add the concept of "read only or not" to "resource assets" (resource assets = assets with import files). Previously Godot assumed any resource asset was read only. PackedScenes and GDScripts are not read only and can be edited/saved directly.

We've been using the .escn concept for writable packed scenes. Maybe we can extend it to .eres?

Edited:

I am against adding writablity to resource assets as a general concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants