godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.05k stars 65 forks source link

Expand `EditorExportPlugin` capabilities #9634

Open and-rad opened 2 weeks ago

and-rad commented 2 weeks ago

Describe the project you are working on

A game that needs to perform a number of automated tasks when exporting a shipping build.

Describe the problem or limitation you are having in your project

An export plugin performs various checks on the files in the project. It needs to log the results in a highly visible region of the editor and has to be able to fail the export if certain conditions are not met. From what I can gather, neither of these things are possible right now.

The EditorExportPlugin class does not provide an API to cancel the export or log a message to the exporter output window. I can log to the regular editor output, but that place is not visible enough to satisfy the high visibility requirement.

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

Expand the class to contain at least 2 new virtual methods, callable from GDScript:

  1. The method returns a bool value that indicates success. In the context of exporting, that would be whether the export process should continue or be cancelled, optionally with an error message. Users override this method if they need to be able to stop the export process. The parent implementation defaults to true.
  2. The method allows to send log/warning/error messages directly to the export output log, where they will be displayed along with any other messages that are collected by the export process along the way.

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

See the section above.

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

Not to my knowledge. Logging to regular output is still an option, but cancelling the export does not seem to be possible.

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

It is part of the core functionality.

raulsntos commented 2 weeks ago

PR https://github.com/godotengine/godot/pull/90782 exposes a way to get the EditorExportPlatform from an EditorExportPlugin. With this you can use the add_message method to add messages to the exporter output window, if any error messages were added then it should also fail the export process.

and-rad commented 2 weeks ago

Sounds good, I did see add_message in the export platform base class, but none of it is exposed to GDScript. I'll keep an eye on that PR.