godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.26k stars 101 forks source link

Allow customization of resources by multiple `EditorExportPlugin`s so it works with features like the shader baker and script tokenizer #12585

Open ydeltastar opened 1 month ago

ydeltastar commented 1 month ago

Describe the project you are working on

A project with various procedural and generated resources that are customized or baked during the export process.

Describe the problem or limitation you are having in your project

I want features like the shader baker or the GDScript binary tokenizer to process my customized resources when I export the project. The issue is that EditorExportPlugin._customize_resource() only works once. If I customize materials using an EditorExportPlugin, for example, these materials are not included in the shader baker processing, which is another EditorExportPlugin.

More use case examples:

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Some options:

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Currently, the processing loop breaks when a resource is modified once. https://github.com/godotengine/godot/blob/51b0379e5502402d44818a4b6f301f544a5754f3/editor/export/editor_export_platform.cpp#L745-L755

Each plugin could run for all resources in sequence instead. A method add_resource/scene() to add to the next process will help with cases like a material cache resource that creates and holds material variations.

for (Ref<EditorExportPlugin> &plugin : customize_resources_plugins) {
    for (Ref<Resource> &res : resource_array) {
        plugin->_customize_resource(res, "");
    }
    // List of new resources created by calling add_resource()
    resource_array.append(plugin->get_new_resources());
}

If this enhancement will not be used often, can it be worked around with a few lines of script?

No.

Is there a reason why this should be core and not an add-on in the asset library?

Can't change the internal exporting process with an addon.