@@ -81,6 +81,17 @@ def load(self, files: list):
8181 }
8282 )
8383
84+ def _load_split_file (self , basename ):
85+ file = []
86+ for i in range (0 , 999 ):
87+ item = f"{ basename } .split{ i } "
88+ if self .fs .exists (item ):
89+ with self .fs .open (item , "rb" ) as f :
90+ file .append (f .read ())
91+ elif i :
92+ break
93+ return b"" .join (file )
94+
8495 def load_file (
8596 self ,
8697 file : Union [io .IOBase , str ],
@@ -95,29 +106,25 @@ def load_file(
95106 split_match = reSplit .match (file )
96107 if split_match :
97108 basepath , basename = split_match .groups ()
98- file = []
99- for i in range (0 , 999 ):
100- item = f"{ basepath } .split{ i } "
101- if self .fs .exists (item ):
102- with self .fs .open (item , "rb" ) as f :
103- file .append (f .read ())
104- elif i :
105- break
106109 name = basepath
107- file = b"" . join ( file )
110+ file = self . _load_split_file ( name )
108111 else :
109112 name = file
110113 if not os .path .exists (file ):
111114 # relative paths are in the asset directory, not the cwd
112115 if not os .path .isabs (file ):
113116 file = os .path .join (self .path , file )
117+ # for dependency loading of split files
118+ if os .path .exists (f"{ file } .split0" ):
119+ file = self ._load_split_file (file )
114120 # Unity paths are case insensitive, so we need to find "Resources/Foo.asset" when the record says "resources/foo.asset"
115- if not os .path .exists (file ):
121+ elif not os .path .exists (file ):
116122 file = ImportHelper .find_sensitive_path (self .path , file )
117123 # nonexistent files might be packaging errors or references to Unity's global Library/
118124 if file is None :
119125 return
120- file = self .fs .open (file , "rb" )
126+ if type (file ) == str :
127+ file = self .fs .open (file , "rb" )
121128
122129 typ , reader = ImportHelper .check_file_type (file )
123130
@@ -273,15 +280,7 @@ def load_assets(self, assets: List[str], open_f: Callable[[str], io.IOBase]):
273280 continue
274281
275282 split_files .append (basepath )
276- data = []
277- for i in range (0 , 999 ):
278- item = f"{ basepath } .split{ i } "
279- if item in assets :
280- with open_f (item ) as f :
281- data .append (f .read ())
282- elif i :
283- break
284- data = b"" .join (data )
283+ data = self ._load_split_file (basepath )
285284 path = basepath
286285 else :
287286 data = open_f (path ).read ()
0 commit comments