remove caching to keep it simple for now

This commit is contained in:
vis2k 2019-04-12 11:57:47 +02:00
parent 80d72c804d
commit a82367b2c6

View File

@ -14,8 +14,6 @@ public static class CompilationFinishedHook
const string MirrorRuntimeAssemblyName = "Mirror"; const string MirrorRuntimeAssemblyName = "Mirror";
const string MirrorWeaverAssemblyName = "Mirror.Weaver"; const string MirrorWeaverAssemblyName = "Mirror.Weaver";
private static UnityAssembly[] _cachedAssemblies;
public static Action<string> OnWeaverMessage; // delegate for subscription to Weaver debug messages public static Action<string> OnWeaverMessage; // delegate for subscription to Weaver debug messages
public static Action<string> OnWeaverWarning; // delegate for subscription to Weaver warning messages public static Action<string> OnWeaverWarning; // delegate for subscription to Weaver warning messages
public static Action<string> OnWeaverError; // delete for subscription to Weaver error messages public static Action<string> OnWeaverError; // delete for subscription to Weaver error messages
@ -48,15 +46,12 @@ static void HandleError(string msg)
[InitializeOnLoadMethod] [InitializeOnLoadMethod]
static void OnInitializeOnLoad() static void OnInitializeOnLoad()
{ {
// pipeline assemblies are valid until the next call to OnInitializeOnLoad
_cachedAssemblies = CompilationPipeline.GetAssemblies();
CompilationPipeline.assemblyCompilationFinished += OnCompilationFinished; CompilationPipeline.assemblyCompilationFinished += OnCompilationFinished;
} }
static string FindMirrorRuntime() static string FindMirrorRuntime()
{ {
foreach (UnityAssembly assembly in _cachedAssemblies) foreach (UnityAssembly assembly in CompilationPipeline.GetAssemblies())
{ {
if (assembly.name == MirrorRuntimeAssemblyName) if (assembly.name == MirrorRuntimeAssemblyName)
{ {
@ -120,7 +115,7 @@ static void OnCompilationFinished(string assemblyPath, CompilerMessage[] message
// build directory list for later asm/symbol resolving using CompilationPipeline refs // build directory list for later asm/symbol resolving using CompilationPipeline refs
HashSet<string> dependencyPaths = new HashSet<string>(); HashSet<string> dependencyPaths = new HashSet<string>();
dependencyPaths.Add(Path.GetDirectoryName(assemblyPath)); dependencyPaths.Add(Path.GetDirectoryName(assemblyPath));
foreach (UnityAssembly unityAsm in _cachedAssemblies) foreach (UnityAssembly unityAsm in CompilationPipeline.GetAssemblies())
{ {
if (unityAsm.outputPath != assemblyPath) continue; if (unityAsm.outputPath != assemblyPath) continue;