@@ -53,7 +53,7 @@ public static void LoadAll()
5353 {
5454 foreach ( var nativeFunction in dll . functions )
5555 {
56- LoadTargetFunction ( nativeFunction ) ;
56+ LoadTargetFunction ( nativeFunction , false ) ;
5757 }
5858 }
5959 }
@@ -76,6 +76,8 @@ public static void UnloadAll()
7676 {
7777 if ( dll . handle != IntPtr . Zero )
7878 {
79+ LowLevelPluginManager . OnBeforeDllUnload ( dll ) ;
80+
7981 bool success = SysUnloadDll ( dll . handle ) ;
8082 dll . handle = IntPtr . Zero ;
8183
@@ -198,7 +200,7 @@ private static DynamicMethod GetNativeFunctionMockMethod(MethodInfo nativeMethod
198200 _dlls . Add ( dllName , dll ) ;
199201 }
200202
201- var nativeFunction = new NativeFunction ( new NativeFunctionIdentity ( nativeFunctionSymbol , dllName ) , dll ) ;
203+ var nativeFunction = new NativeFunction ( nativeFunctionSymbol , dll ) ;
202204 dll . functions . Add ( nativeFunction ) ;
203205 var nativeFunctionIndex = _nativeFunctionsCount ;
204206 AddNativeFunction ( nativeFunction ) ;
@@ -255,6 +257,7 @@ private static void GenerateNativeFunctionMockBody(ILGenerator il, ParameterInfo
255257 throw new InvalidOperationException ( "Thread safety with Lazy mode is not supported" ) ;
256258
257259 il . Emit ( OpCodes . Dup ) ;
260+ il . Emit ( OpCodes . Ldc_I4_0 ) ; //ignoreLoadErrors -> false
258261 il . Emit ( OpCodes . Call , Method_LoadTargetFunction . Value ) ;
259262 }
260263
@@ -430,21 +433,27 @@ private static CustomAttributeBuilder CreateMarshalingAttributeBuilderFromAttrib
430433 /// To achieve thread safety calls to this method must be synchronized.
431434 /// Note: This method is being called by dynamically generated code. Be careful when changing its signature.
432435 /// </summary>
433- private static void LoadTargetFunction ( NativeFunction nativeFunction )
436+ internal static void LoadTargetFunction ( NativeFunction nativeFunction , bool ignoreLoadError )
434437 {
435438 var dll = nativeFunction . containingDll ;
436439 if ( dll . handle == IntPtr . Zero )
437440 {
438441 dll . handle = SysLoadDll ( dll . path ) ;
439442 if ( dll . handle == IntPtr . Zero )
440443 {
441- dll . loadingError = true ;
442- Prop_EditorApplication_isPaused . Value ? . SetValue ( null , true ) ;
443- throw new NativeDllException ( $ "Could not load DLL \" { dll . name } \" at path \" { dll . path } \" .") ;
444+ if ( ! ignoreLoadError )
445+ {
446+ dll . loadingError = true ;
447+ Prop_EditorApplication_isPaused . Value ? . SetValue ( null , true ) ;
448+ throw new NativeDllException ( $ "Could not load DLL \" { dll . name } \" at path \" { dll . path } \" .") ;
449+ }
450+
451+ return ;
444452 }
445453 else
446454 {
447455 dll . loadingError = false ;
456+ LowLevelPluginManager . OnDllLoaded ( dll ) ;
448457 }
449458 }
450459
@@ -453,9 +462,14 @@ private static void LoadTargetFunction(NativeFunction nativeFunction)
453462 IntPtr funcPtr = SysGetDllProcAddress ( dll . handle , nativeFunction . identity . symbol ) ;
454463 if ( funcPtr == IntPtr . Zero )
455464 {
456- dll . symbolError = true ;
457- Prop_EditorApplication_isPaused . Value ? . SetValue ( null , true ) ;
458- throw new NativeDllException ( $ "Could not get address of symbol \" { nativeFunction . identity . symbol } \" in DLL \" { dll . name } \" at path \" { dll . path } \" .") ;
465+ if ( ! ignoreLoadError )
466+ {
467+ dll . symbolError = true ;
468+ Prop_EditorApplication_isPaused . Value ? . SetValue ( null , true ) ;
469+ throw new NativeDllException ( $ "Could not get address of symbol \" { nativeFunction . identity . symbol } \" in DLL \" { dll . name } \" at path \" { dll . path } \" .") ;
470+ }
471+
472+ return ;
459473 }
460474 else
461475 {
0 commit comments