@@ -292,8 +292,9 @@ public ReusableWaitForSecondsRealtime(float time)
292292 const string PLUGIN_PATH = "/Plugins/Editor/libNativeScript.so" ;
293293#elif UNITY_EDITOR_WIN
294294 const string PLUGIN_PATH = "/Plugins/Editor/NativeScript.dll" ;
295+ const string PLUGIN_TEMP_PATH = "/Plugins/Editor/NativeScript_temp.dll" ;
295296#endif
296-
297+
297298 enum InitMode : byte
298299 {
299300 FirstBoot ,
@@ -1517,6 +1518,9 @@ IntPtr systemComponentModelDesignComponentRenameEventHandlerInvoke
15171518 /*END DELEGATE TYPES*/
15181519
15191520 private static readonly string pluginPath = Application . dataPath + PLUGIN_PATH ;
1521+ #if UNITY_EDITOR_WIN
1522+ private static readonly string pluginTempPath = Application . dataPath + PLUGIN_TEMP_PATH ;
1523+ #endif
15201524 public static Exception UnhandledCppException ;
15211525 public static SetCsharpExceptionDelegate SetCsharpException ;
15221526 private static IntPtr memory ;
@@ -1602,8 +1606,16 @@ ReusableWaitForSecondsRealtime poll
16021606 private static void OpenPlugin ( InitMode initMode )
16031607 {
16041608#if UNITY_EDITOR
1609+ string loadPath ;
1610+ #if UNITY_EDITOR_WIN
1611+ // Copy native library to temporary file
1612+ File . Copy ( pluginPath , pluginTempPath ) ;
1613+ loadPath = pluginTempPath ;
1614+ #else
1615+ loadPath = pluginPath ;
1616+ #endif
16051617 // Open native library
1606- libraryHandle = OpenLibrary ( pluginPath ) ;
1618+ libraryHandle = OpenLibrary ( loadPath ) ;
16071619 InitDelegate Init = GetDelegate < InitDelegate > (
16081620 libraryHandle ,
16091621 "Init" ) ;
@@ -1967,6 +1979,9 @@ private static void ClosePlugin()
19671979#if UNITY_EDITOR
19681980 CloseLibrary ( libraryHandle ) ;
19691981 libraryHandle = IntPtr . Zero ;
1982+ #endif
1983+ #if UNITY_EDITOR_WIN
1984+ File . Delete ( pluginTempPath ) ;
19701985#endif
19711986 }
19721987
0 commit comments