@@ -27,6 +27,7 @@ public AssetsFileInstance LoadAssetsFile(Stream stream, string path, bool loadDe
2727 if ( index == - 1 )
2828 {
2929 instance = new AssetsFileInstance ( stream , path , root ) ;
30+ instance . parentBundle = bunInst ;
3031 files . Add ( instance ) ;
3132 }
3233 else
@@ -289,33 +290,52 @@ public void LoadBundleDependencies(AssetsFileInstance ofFile, BundleFileInstance
289290 #region asset resolving
290291 public AssetExternal GetExtAsset ( AssetsFileInstance relativeTo , int fileId , long pathId , bool onlyGetInfo = false , bool forceFromCldb = false )
291292 {
292- AssetExternal ext = new AssetExternal ( ) ;
293+ AssetExternal ext = new AssetExternal
294+ {
295+ info = null ,
296+ instance = null ,
297+ file = null
298+ } ;
299+
293300 if ( fileId == 0 && pathId == 0 )
294301 {
295- ext . info = null ;
296- ext . instance = null ;
297- ext . file = null ;
302+ return ext ;
298303 }
299304 else if ( fileId != 0 )
300305 {
301306 AssetsFileInstance dep = relativeTo . GetDependency ( this , fileId - 1 ) ;
307+
308+ if ( dep == null )
309+ return ext ;
310+
302311 ext . info = dep . table . GetAssetInfo ( pathId ) ;
312+
313+ if ( ext . info == null )
314+ return ext ;
315+
303316 if ( ! onlyGetInfo )
304317 ext . instance = GetTypeInstance ( dep . file , ext . info , forceFromCldb ) ;
305318 else
306319 ext . instance = null ;
320+
307321 ext . file = dep ;
322+ return ext ;
308323 }
309324 else
310325 {
311326 ext . info = relativeTo . table . GetAssetInfo ( pathId ) ;
327+
328+ if ( ext . info == null )
329+ return ext ;
330+
312331 if ( ! onlyGetInfo )
313332 ext . instance = GetTypeInstance ( relativeTo . file , ext . info , forceFromCldb ) ;
314333 else
315334 ext . instance = null ;
335+
316336 ext . file = relativeTo ;
337+ return ext ;
317338 }
318- return ext ;
319339 }
320340
321341 public AssetExternal GetExtAsset ( AssetsFileInstance relativeTo , AssetTypeValueField atvf , bool onlyGetInfo = false , bool forceFromCldb = false )
@@ -389,11 +409,16 @@ public AssetTypeValueField GetMonoBaseFieldCached(AssetsFileInstance inst, Asset
389409 if ( ! inst . monoIdToName . ContainsKey ( scriptIndex ) )
390410 {
391411 AssetTypeInstance scriptAti = GetExtAsset ( inst , GetTypeInstance ( inst . file , info ) . GetBaseField ( ) . Get ( "m_Script" ) ) . instance ;
412+
413+ //couldn't find asset
414+ if ( scriptAti == null )
415+ return null ;
416+
392417 scriptName = scriptAti . GetBaseField ( ) . Get ( "m_Name" ) . GetValue ( ) . AsString ( ) ;
393418 string scriptNamespace = scriptAti . GetBaseField ( ) . Get ( "m_Namespace" ) . GetValue ( ) . AsString ( ) ;
394419 string assemblyName = scriptAti . GetBaseField ( ) . Get ( "m_AssemblyName" ) . GetValue ( ) . AsString ( ) ;
395420
396- if ( scriptNamespace ! = string . Empty )
421+ if ( scriptNamespace = = string . Empty )
397422 {
398423 scriptNamespace = "-" ;
399424 }
0 commit comments