@@ -11,13 +11,16 @@ const MATERIAL_KEYS_TO_IMPORT = [
1111
1212static var has_imported_resources : bool = false ;
1313
14- static func for_resource_import () -> void :
15- var editor_interface = Engine .get_singleton ("EditorInterface" ) if Engine .is_editor_hint () else null ;
16- if not editor_interface : return ;
14+ static func get_editor_interface ():
15+ return Engine .get_singleton ("EditorInterface" ) if Engine .has_singleton ("EditorInterface" ) else null ;
1716
18- var fs = editor_interface . get_resource_filesystem () if Engine . is_editor_hint () else null ;
17+ static func for_resource_import () -> void :
1918 if not has_imported_resources : return ;
2019
20+ var editor_interface = get_editor_interface ();
21+ if not editor_interface : return null ;
22+
23+ var fs = editor_interface .get_resource_filesystem ();
2124 if not fs : return ;
2225
2326 fs .scan ();
@@ -84,7 +87,7 @@ static func import_material(material: String) -> bool:
8487 return true ;
8588
8689static func import_materials (vmf_structure : VMFStructure , is_runtime := false ) -> void :
87- var editor_interface = Engine . get_singleton ( "EditorInterface" ) if Engine . is_editor_hint () else null ;
90+ var editor_interface = get_editor_interface () ;
8891
8992 if VMFConfig .materials .import_mode == VMFConfig .MaterialsConfig .ImportMode .USE_EXISTING :
9093 return ;
@@ -114,8 +117,6 @@ static func import_materials(vmf_structure: VMFStructure, is_runtime := false) -
114117 list .append (side .material );
115118
116119 if not is_runtime and editor_interface :
117- var fs = editor_interface .get_resource_filesystem () if Engine .is_editor_hint () else null ;
118-
119120 for material in list :
120121 import_textures (material );
121122
0 commit comments