diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index c9cfbdd4cb6c..66ef418e42db 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -263,6 +263,15 @@ void ScriptServer::remove_global_class(const StringName &p_class) { global_classes.erase(p_class); } +void ScriptServer::remove_global_class_by_path(const String &p_path) { + for (const KeyValue &kv : global_classes) { + if (kv.value.path == p_path) { + global_classes.erase(kv.key); + return; + } + } +} + bool ScriptServer::is_global_class(const StringName &p_class) { return global_classes.has(p_class); } diff --git a/core/object/script_language.h b/core/object/script_language.h index ff678bcd25a3..02d1880dc2fe 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -80,6 +80,7 @@ public: static void global_classes_clear(); static void add_global_class(const StringName &p_class, const StringName &p_base, const StringName &p_language, const String &p_path); static void remove_global_class(const StringName &p_class); + static void remove_global_class_by_path(const String &p_path); static bool is_global_class(const StringName &p_class); static StringName get_global_class_language(const StringName &p_class); static String get_global_class_path(const String &p_class); diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index cddf3662aa21..5f33c68a7d8c 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -71,12 +71,6 @@ This will not import the file. To reimport, call [method reimport_files] or [method scan] methods. - - - - Scans the script files and updates the list of custom class names. - - diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 9c056ffdd972..63008ec65c1a 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -602,10 +602,19 @@ bool EditorFileSystem::_update_scan_actions() { fs_changed = true; + if (ClassDB::is_parent_class(ia.new_file->type, SNAME("Script"))) { + _queue_update_script_class(ia.dir->get_file_path(idx)); + } + } break; case ItemAction::ACTION_FILE_REMOVE: { int idx = ia.dir->find_file_index(ia.file); ERR_CONTINUE(idx == -1); + + if (ClassDB::is_parent_class(ia.dir->files[idx]->type, SNAME("Script"))) { + _queue_update_script_class(ia.dir->get_file_path(idx)); + } + _delete_internal_files(ia.dir->files[idx]->file); memdelete(ia.dir->files[idx]); ia.dir->files.remove_at(idx); @@ -640,6 +649,10 @@ bool EditorFileSystem::_update_scan_actions() { ERR_CONTINUE(idx == -1); String full_path = ia.dir->get_file_path(idx); + if (ClassDB::is_parent_class(ia.dir->files[idx]->type, SNAME("Script"))) { + _queue_update_script_class(full_path); + } + reloads.push_back(full_path); } break; @@ -710,7 +723,6 @@ void EditorFileSystem::scan() { scanning = false; emit_signal(SNAME("filesystem_changed")); emit_signal(SNAME("sources_changed"), sources_changed.size() > 0); - _queue_update_script_classes(); first_scan = false; } else { ERR_FAIL_COND(thread.is_started()); @@ -922,20 +934,6 @@ void EditorFileSystem::_scan_new_dir(EditorFileSystemDirectory *p_dir, Refsupports_documentation() && fi->type == lang->get_type()) { - Ref