@@ -1578,31 +1578,7 @@ void EditorFileSystem::_update_script_classes() {
1578
1578
update_script_mutex.lock ();
1579
1579
1580
1580
for (const String &path : update_script_paths) {
1581
- ScriptServer::remove_global_class_by_path (path); // First remove, just in case it changed
1582
-
1583
- int index = -1 ;
1584
- EditorFileSystemDirectory *efd = find_file (path, &index);
1585
-
1586
- if (!efd || index < 0 ) {
1587
- // The file was removed
1588
- continue ;
1589
- }
1590
-
1591
- if (!efd->files [index]->script_class_name .is_empty ()) {
1592
- String lang;
1593
- for (int j = 0 ; j < ScriptServer::get_language_count (); j++) {
1594
- if (ScriptServer::get_language (j)->handles_global_class_type (efd->files [index]->type )) {
1595
- lang = ScriptServer::get_language (j)->get_name ();
1596
- }
1597
- }
1598
- if (lang.is_empty ()) {
1599
- continue ; // No lang found that can handle this global class
1600
- }
1601
-
1602
- ScriptServer::add_global_class (efd->files [index]->script_class_name , efd->files [index]->script_class_extends , lang, path);
1603
- EditorNode::get_editor_data ().script_class_set_icon_path (efd->files [index]->script_class_name , efd->files [index]->script_class_icon_path );
1604
- EditorNode::get_editor_data ().script_class_set_name (path, efd->files [index]->script_class_name );
1605
- }
1581
+ EditorFileSystem::get_singleton ()->register_global_class_script (path, path);
1606
1582
}
1607
1583
1608
1584
// Parse documentation second, as it requires the class names to be correct and registered
@@ -1844,6 +1820,34 @@ HashSet<String> EditorFileSystem::get_valid_extensions() const {
1844
1820
return valid_extensions;
1845
1821
}
1846
1822
1823
+ void EditorFileSystem::register_global_class_script (const String &p_search_path, const String &p_target_path) {
1824
+ ScriptServer::remove_global_class_by_path (p_search_path); // First remove, just in case it changed
1825
+
1826
+ int index = -1 ;
1827
+ EditorFileSystemDirectory *efd = find_file (p_search_path, &index);
1828
+
1829
+ if (!efd || index < 0 ) {
1830
+ // The file was removed
1831
+ return ;
1832
+ }
1833
+
1834
+ if (!efd->files [index]->script_class_name .is_empty ()) {
1835
+ String lang;
1836
+ for (int j = 0 ; j < ScriptServer::get_language_count (); j++) {
1837
+ if (ScriptServer::get_language (j)->handles_global_class_type (efd->files [index]->type )) {
1838
+ lang = ScriptServer::get_language (j)->get_name ();
1839
+ }
1840
+ }
1841
+ if (lang.is_empty ()) {
1842
+ return ; // No lang found that can handle this global class
1843
+ }
1844
+
1845
+ ScriptServer::add_global_class (efd->files [index]->script_class_name , efd->files [index]->script_class_extends , lang, p_target_path);
1846
+ EditorNode::get_editor_data ().script_class_set_icon_path (efd->files [index]->script_class_name , efd->files [index]->script_class_icon_path );
1847
+ EditorNode::get_editor_data ().script_class_set_name (p_target_path, efd->files [index]->script_class_name );
1848
+ }
1849
+ }
1850
+
1847
1851
Error EditorFileSystem::_reimport_group (const String &p_group_file, const Vector<String> &p_files) {
1848
1852
String importer_name;
1849
1853
0 commit comments