Include EditorModules in Assembly lookup paths
This commit is contained in:
@@ -184,7 +184,7 @@ namespace FlaxEngine.Interop
|
||||
{
|
||||
string moduleName = Marshal.PtrToStringAnsi(moduleNamePtr);
|
||||
string modulePath = Marshal.PtrToStringAnsi(modulePathPtr);
|
||||
nativeLibraryPaths[moduleName] = modulePath;
|
||||
libraryPaths[moduleName] = modulePath;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
@@ -909,7 +909,7 @@ namespace FlaxEngine.Interop
|
||||
loadedNativeLibraries.Remove(nativeLibraryName);
|
||||
}
|
||||
if (nativeLibraryName != null)
|
||||
nativeLibraryPaths.Remove(nativeLibraryName);
|
||||
libraryPaths.Remove(nativeLibraryName);
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace FlaxEngine.Interop
|
||||
private static Dictionary<Type, int> _typeSizeCache = new();
|
||||
|
||||
private static Dictionary<string, IntPtr> loadedNativeLibraries = new();
|
||||
internal static Dictionary<string, string> nativeLibraryPaths = new();
|
||||
internal static Dictionary<string, string> libraryPaths = new();
|
||||
private static Dictionary<Assembly, string> assemblyOwnedNativeLibraries = new();
|
||||
internal static AssemblyLoadContext scriptingAssemblyLoadContext;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace FlaxEngine.Interop
|
||||
{
|
||||
if (!loadedNativeLibraries.TryGetValue(libraryName, out IntPtr nativeLibrary))
|
||||
{
|
||||
if (!nativeLibraryPaths.TryGetValue(libraryName, out var nativeLibraryPath))
|
||||
if (!libraryPaths.TryGetValue(libraryName, out var nativeLibraryPath))
|
||||
nativeLibraryPath = libraryName;
|
||||
|
||||
nativeLibrary = NativeLibrary.Load(nativeLibraryPath, assembly, dllImportSearchPath);
|
||||
@@ -101,9 +101,9 @@ namespace FlaxEngine.Interop
|
||||
private static Assembly OnScriptingAssemblyLoadContextResolving(AssemblyLoadContext assemblyLoadContext, AssemblyName assemblyName)
|
||||
{
|
||||
// FIXME: There should be a better way to resolve the path to EditorTargetPath where the dependencies are stored
|
||||
foreach (string nativeLibraryPath in nativeLibraryPaths.Values)
|
||||
foreach (string libraryPath in libraryPaths.Values)
|
||||
{
|
||||
string editorTargetPath = Path.GetDirectoryName(nativeLibraryPath);
|
||||
string editorTargetPath = Path.GetDirectoryName(libraryPath);
|
||||
|
||||
var assemblyPath = Path.Combine(editorTargetPath, assemblyName.Name + ".dll");
|
||||
if (File.Exists(assemblyPath))
|
||||
|
||||
@@ -719,6 +719,13 @@ bool MAssembly::LoadImage(const String& assemblyPath, const StringView& nativePa
|
||||
StringAnsi nativeName = _name.EndsWith(".CSharp") ? StringAnsi(_name.Get(), _name.Length() - 7) : StringAnsi(_name);
|
||||
RegisterNativeLibrary(nativeName.Get(), StringAnsi(nativePath).Get());
|
||||
}
|
||||
#if USE_EDITOR
|
||||
// Register the editor module location for Assembly resolver
|
||||
else
|
||||
{
|
||||
RegisterNativeLibrary(_name.Get(), StringAnsi(assemblyPath).Get());
|
||||
}
|
||||
#endif
|
||||
|
||||
_hasCachedClasses = false;
|
||||
_assemblyPath = assemblyPath;
|
||||
|
||||
Reference in New Issue
Block a user