godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.1k stars 69 forks source link

Allow running the resource importing process manually instead of automatically #9852

Open Souchy opened 2 months ago

Souchy commented 2 months ago

Describe the project you are working on

Any

Describe the problem or limitation you are having in your project

The import process currently runs constantly in the background, scanning files for modifications and importing them.

In projects where you add a lot of assets this:

Some things are good to automatically rescan, like when duplicating/moving/renaming a file or modifying scripts externally. But they should all have their own option like text_editor/behavior/files/auto_reload_scripts_on_external_change.

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

  1. Add an option to make the import process completely manual, automatic like now, or run at a set interval.
  2. Add a context menu button in the file explorer to run the process on selected folders and files.

Having this means:

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

Add the editor or project option: editor/import/scan_process = [Automatic, Manual] And a scan/import button:

  1. Add a menu option: FileMenu::FILE_IMPORT
  2. In FileSystemDock::_file_and_folders_fill_popup:
    p_popup->add_icon_item(get_editor_theme_icon(SNAME("Import")), TTR("Import selected"), FILE_IMPORT);
  3. In FileSystemDock::_file_option:
    case FILE_IMPORT: {
    // Scan & import files
    for (int i = 0; i < p_selected.size(); i++) {
                scan(p_selected[i];
    }
    } break;
  4. Modify the EditorFileSystem::scan and EditorFileSystem::_scan_filesystem function to allow one or a list of paths to scan.

I see that Juan removed this in 2017, it would be good to have a form of it back πŸ˜ƒ but with improvements to run it on selected paths image https://github.com/godotengine/godot/commit/0f7af4ea51744cda23c4d3c7481f9c332973d1d4#diff-ad87f37b9328524f59e7b09f722ca25a46d066216418ae50de3eae435d13b52fL491

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?

Requires core modifications.

Calinou commented 2 months ago

There might be good reasons not to allow this due to the inconsistent state the editor could be left in if the user doesn't reimport modified resources for a long time. If we're not careful, we run the risk of things like data loss occurring.

https://github.com/godotengine/godot/pull/76991 likely addresses parts of the concerns outlined here, as the import process will begin before you've refocused the editor. The editor will still not be interactable while resources are importing, but it's more likely the import process will have finished by the time you alt-tab back to the editor.

I see that Juan removed this in 2017, it would be good to have a form of it back πŸ˜ƒ but with improvements to run it on selected paths

The setting had debug in its name, so I don't think it was intended for production.