diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 9ed159bd203..4d980bcf1a5 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -31,6 +31,7 @@ #include "resource_importer.h" #include "core/os/os.h" +#include "core/project_settings.h" #include "core/variant_parser.h" bool ResourceFormatImporter::SortImporterByName::operator()(const Ref &p_a, const Ref &p_b) const { @@ -374,7 +375,7 @@ Ref ResourceFormatImporter::get_importer_by_extension(const St } String ResourceFormatImporter::get_import_base_path(const String &p_for_file) const { - return "res://.import/" + p_for_file.get_file() + "-" + p_for_file.md5_text(); + return ProjectSettings::IMPORTED_FILES_PATH.plus_file(p_for_file.get_file() + "-" + p_for_file.md5_text()); } bool ResourceFormatImporter::are_import_settings_valid(const String &p_path) const { diff --git a/core/project_settings.cpp b/core/project_settings.cpp index efe13e740d2..90f56694c22 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -53,6 +53,8 @@ String ProjectSettings::get_resource_path() const { return resource_path; } +const String ProjectSettings::IMPORTED_FILES_PATH("res://.godot/imported"); + String ProjectSettings::localize_path(const String &p_path) const { if (resource_path == "") { return p_path; //not initialized yet diff --git a/core/project_settings.h b/core/project_settings.h index 29b2406dd23..6cbb02d30e2 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -41,6 +41,7 @@ class ProjectSettings : public Object { public: typedef Map CustomMap; + static const String IMPORTED_FILES_PATH; enum { //properties that are not for built in values begin from this value, so builtin ones are displayed first diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index b2905573360..2a7f27ef55d 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -5,7 +5,7 @@ EditorImportPlugins provide a way to extend the editor's resource import functionality. Use them to import resources from custom files or to provide alternatives to the editor's existing importers. Register your [EditorPlugin] with [method EditorPlugin.add_import_plugin]. - EditorImportPlugins work by associating with specific file extensions and a resource type. See [method get_recognized_extensions] and [method get_resource_type]. They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the [code].import[/code] directory. + EditorImportPlugins work by associating with specific file extensions and a resource type. See [method get_recognized_extensions] and [method get_resource_type]. They may optionally specify some import presets that affect the import process. EditorImportPlugins are responsible for creating the resources and saving them in the [code].godot/imported[/code] directory. Below is an example EditorImportPlugin that imports a [Mesh] from a file with the extension ".special" or ".spec": [codeblock] tool @@ -136,7 +136,7 @@ - Gets the extension used to save this resource in the [code].import[/code] directory. + Gets the extension used to save this resource in the [code].godot/imported[/code] directory. diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index 0e851734a77..ba9f27f65fe 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -559,7 +559,7 @@ void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p continue; } Dictionary item_meta = item_list->get_item_metadata(i); - if (item_meta["path"] == "res://.import") { + if (String(item_meta["path"]).begins_with("res://.godot")) { allow_delete = false; break; } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a5edcf5c22b..5607bb3f171 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1865,13 +1865,14 @@ void EditorFileSystem::_find_group_files(EditorFileSystemDirectory *efd, Map &p_files) { - { //check that .import folder exists + { + // Ensure that ProjectSettings::IMPORTED_FILES_PATH exists. DirAccess *da = DirAccess::open("res://"); - if (da->change_dir(".import") != OK) { - Error err = da->make_dir(".import"); - if (err) { + if (da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { + Error err = da->make_dir_recursive(ProjectSettings::IMPORTED_FILES_PATH); + if (err || da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { memdelete(da); - ERR_FAIL_MSG("Failed to create 'res://.import' folder."); + ERR_FAIL_MSG("Failed to create '" + ProjectSettings::IMPORTED_FILES_PATH + "' folder."); } } memdelete(da); @@ -2055,8 +2056,8 @@ EditorFileSystem::EditorFileSystem() { scanning_changes_done = false; DirAccess *da = DirAccess::create(DirAccess::ACCESS_RESOURCES); - if (da->change_dir("res://.import") != OK) { - da->make_dir("res://.import"); + if (da->change_dir(ProjectSettings::IMPORTED_FILES_PATH) != OK) { + da->make_dir(ProjectSettings::IMPORTED_FILES_PATH); } // This should probably also work on Unix and use the string it returns for FAT32 or exFAT using_fat32_or_exfat = (da->get_filesystem_type() == "FAT32" || da->get_filesystem_type() == "exFAT"); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1fb889d793c..6393aa30ed8 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -2093,7 +2093,8 @@ void ProjectManager::_run_project_confirm() { const String &selected = selected_list[i].project_key; String path = EditorSettings::get_singleton()->get("projects/" + selected); - if (!DirAccess::exists(path + "/.import")) { + // `.right(6)` on `IMPORTED_FILES_PATH` strips away the leading "res://". + if (!DirAccess::exists(path.plus_file(ProjectSettings::IMPORTED_FILES_PATH.right(6)))) { run_error_diag->set_text(TTR("Can't run project: Assets need to be imported.\nPlease edit the project to trigger the initial import.")); run_error_diag->popup_centered(); return;