Skip to content

Commit f815cf2

Browse files
committed
fix: in 2020.2 or later, no need to recompile
1 parent cc648de commit f815cf2

File tree

1 file changed

+3
-20
lines changed
  • Plugins/CSharpCompilerSettings

1 file changed

+3
-20
lines changed

Plugins/CSharpCompilerSettings/Core.cs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,6 @@ internal static class Core
1717
{
1818
private static bool IsGlobal { get; }
1919

20-
public static void DirtyScriptsIfNeeded()
21-
{
22-
var assemblyName = GetAssemblyName(FindAsmdef());
23-
if (!IsGlobal && string.IsNullOrEmpty(assemblyName)) return;
24-
25-
var filepath = "Temp/" + typeof(Core).Assembly.GetName().Name + ".loaded";
26-
if (File.Exists(filepath)) return;
27-
File.WriteAllText(filepath, "");
28-
29-
Utils.RequestCompilation(IsGlobal ? null : assemblyName);
30-
}
31-
3220
public static string GetAssemblyName(string asmdefPath)
3321
{
3422
if (string.IsNullOrEmpty(asmdefPath)) return null;
@@ -268,6 +256,7 @@ public static void OnAssemblyCompilationStarted(string name)
268256

269257
static Core()
270258
{
259+
// For development assemblies: Do nothing.
271260
var coreAssemblyName = typeof(Core).Assembly.GetName().Name;
272261
if (coreAssemblyName == "CSharpCompilerSettings_") return;
273262

@@ -315,21 +304,15 @@ static Core()
315304
CompilationPipeline.assemblyCompilationStarted -= OnAssemblyCompilationStarted;
316305
CompilationPipeline.assemblyCompilationStarted += OnAssemblyCompilationStarted;
317306

318-
// Install custom csc before compilation.
307+
// Install custom compiler package before compilation.
319308
var settings = GetSettings();
320309
if (!settings.UseDefaultCompiler)
321310
CompilerInfo.GetInstalledInfo(settings.CompilerPackage.PackageId);
322311

312+
// Install analyzer packages before compilation.
323313
if (IsGlobal)
324314
foreach (var package in settings.AnalyzerPackages.Where(x => x.IsValid))
325315
AnalyzerInfo.GetInstalledInfo(package.PackageId);
326-
327-
// If Unity 2020.2 or newer, request re-compilation.
328-
var version = Application.unityVersion.Split('.');
329-
var major = int.Parse(version[0]);
330-
var minor = int.Parse(version[1]);
331-
if (2021 <= major || (major == 2020 && 2 <= minor))
332-
DirtyScriptsIfNeeded();
333316
}
334317
}
335318
}

0 commit comments

Comments
 (0)