From 41824c6cc81c470a97d19269173aea8d53292da8 Mon Sep 17 00:00:00 2001 From: Lyuma Date: Fri, 13 May 2022 10:35:12 -0700 Subject: [PATCH] Bind EditorFileSystem::reimport_files and improve docs reimport_files offers a way for scripts to modify imported resources directly. For example, images, sounds or glTF documents which are written by an external program. It is much faster than `scan`, and can allow scripts to synchronously proceed after import finishes. --- doc/classes/EditorFileSystem.xml | 12 +++++++++++- editor/editor_file_system.cpp | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index 300cb4bfd64..60ac499d253 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -42,6 +42,15 @@ Returns [code]true[/code] of the filesystem is being scanned. + + + + + Reimports a set of files. Call this if these files or their [code].import[/code] files were directly edited by script or an external program. + If the file type changed or the file was newly created, use [method update_file] or [method scan]. + [b]Note:[/b] This function blocks until the import is finished. However, the main loop iteration, including timers and [method Node._process], will occur during the import process due to progress bar updates. Avoid calls to [method reimport_files] or [method scan] while an import is in progress. + + @@ -58,7 +67,8 @@ - Update a file information. Call this if an external program (not Godot) modified the file. + Add a file in an existing directory, or schedule file information to be updated on editor restart. Can be used to update text files saved by an external program. + This will not import the file. To reimport, call [method reimport_files] or [method scan] methods. diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 36ac9afca8b..56edb031847 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -2372,6 +2372,7 @@ void EditorFileSystem::_bind_methods() { ClassDB::bind_method(D_METHOD("get_filesystem_path", "path"), &EditorFileSystem::get_filesystem_path); ClassDB::bind_method(D_METHOD("get_file_type", "path"), &EditorFileSystem::get_file_type); ClassDB::bind_method(D_METHOD("update_script_classes"), &EditorFileSystem::update_script_classes); + ClassDB::bind_method(D_METHOD("reimport_files", "files"), &EditorFileSystem::reimport_files); ADD_SIGNAL(MethodInfo("filesystem_changed")); ADD_SIGNAL(MethodInfo("sources_changed", PropertyInfo(Variant::BOOL, "exist")));