From f815cf2c7c270afca6bca019d0fc6eb42b4c4348 Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Mon, 21 Dec 2020 10:14:30 +0900 Subject: [PATCH] fix: in 2020.2 or later, no need to recompile --- Plugins/CSharpCompilerSettings/Core.cs | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/Plugins/CSharpCompilerSettings/Core.cs b/Plugins/CSharpCompilerSettings/Core.cs index fe9a32d..29803f3 100644 --- a/Plugins/CSharpCompilerSettings/Core.cs +++ b/Plugins/CSharpCompilerSettings/Core.cs @@ -17,18 +17,6 @@ internal static class Core { private static bool IsGlobal { get; } - public static void DirtyScriptsIfNeeded() - { - var assemblyName = GetAssemblyName(FindAsmdef()); - if (!IsGlobal && string.IsNullOrEmpty(assemblyName)) return; - - var filepath = "Temp/" + typeof(Core).Assembly.GetName().Name + ".loaded"; - if (File.Exists(filepath)) return; - File.WriteAllText(filepath, ""); - - Utils.RequestCompilation(IsGlobal ? null : assemblyName); - } - public static string GetAssemblyName(string asmdefPath) { if (string.IsNullOrEmpty(asmdefPath)) return null; @@ -268,6 +256,7 @@ public static void OnAssemblyCompilationStarted(string name) static Core() { + // For development assemblies: Do nothing. var coreAssemblyName = typeof(Core).Assembly.GetName().Name; if (coreAssemblyName == "CSharpCompilerSettings_") return; @@ -315,21 +304,15 @@ static Core() CompilationPipeline.assemblyCompilationStarted -= OnAssemblyCompilationStarted; CompilationPipeline.assemblyCompilationStarted += OnAssemblyCompilationStarted; - // Install custom csc before compilation. + // Install custom compiler package before compilation. var settings = GetSettings(); if (!settings.UseDefaultCompiler) CompilerInfo.GetInstalledInfo(settings.CompilerPackage.PackageId); + // Install analyzer packages before compilation. if (IsGlobal) foreach (var package in settings.AnalyzerPackages.Where(x => x.IsValid)) AnalyzerInfo.GetInstalledInfo(package.PackageId); - - // If Unity 2020.2 or newer, request re-compilation. - var version = Application.unityVersion.Split('.'); - var major = int.Parse(version[0]); - var minor = int.Parse(version[1]); - if (2021 <= major || (major == 2020 && 2 <= minor)) - DirtyScriptsIfNeeded(); } } }