Skip to content

Allow defining what importer to use for a given file extension #2500

Open
@akien-mga

Description

Describe the project you are working on

Godot itself, and trying to improve the usability.

Describe the problem or limitation you are having in your project

Godot imports some assets using ResourceImporters, which recognize which file types they handle based on file extensions.

There are several cases where a given extension might be supported by several importers for different outcomes:

Screenshot_20210324_094245
(Texture makes sense as the default as it's the most common use case, but if for some reason your game processes everything from Image, you might want to change that default.)

Screenshot_20210324_094002
(.obj files can be imported as mesh or as scene. In theory, they could also be completely unrelated things like C/C++ compilation objects from MSVC, in which case they would be excluded with "Keep" or a .gitignore file.)

Screenshot_20210324_094031
(The "fake" CSV importer is being removed in godotengine/godot#47301, but this is still a typical situation where you might want to define if you want your CSV files to be imported as translations or kept as is by default.)

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

There should be a way to specify, for a given extension (e.g. png, obj, csv), what should be the default ResourceImporter used to import any newly added asset with this extension.

This should likely be a project setting, and when changed, it would not modify already imported assets, but it would affect any asset imported in the future. The "Import" dock would still allow customizing the behavior and changing what importer to use for given files.

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

godotengine/godot#46354 added an "Importer Defaults" editor tab in the Project Settings:
Screenshot_20210324_094442

This allows customizing the behavior of ResourceImporter themselves.

I suggest splitting this dialog in two, adding a section which would allow selecting the default importer for a given file extension.
This section would populate the list of recognized extensions by querying the engine for registered importers and the extensions they handle, and for each extension, there would be a drop-down list that lets you select a valid importer OR the "Keep" option.

Quick mockup (proper implementation should likely use SectionedEditorInspector or similar):

Screenshot_20210324_095419
Screenshot_20210324_095548

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

Not really, this needs to be a configuration that affects what happens even before a given file is imported when scanned by the FileSystem dock.

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

This is part of the core configuration of any project just like the new "Importer Defaults". It could possibly be done via an add-on that re-imports newly detected files with a chosen importer, but that would be quite hacky and inefficient.

Metadata

Assignees

No one assigned

    Labels

    implementer wantedThis proposal can probably be implemented, if there was a hero to do ittopic:import

    Type

    No type

    Projects

    • Status

      Ready for Implementation

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions