Search Unity

Question Controlling the plugin load order with respect to script compilation

Discussion in 'Editor & General Support' started by davidair_unity, Jan 17, 2023.

  1. davidair_unity

    davidair_unity

    Joined:
    Oct 18, 2021
    Posts:
    1
    We are using IL weaving (for a number of reasons, including forcing generic IL2CPP preservations, but the reasons are not important) and the way we do it is by hooking into CompilationPipeline.assemblyCompilationFinished.

    This works well, but we have a performance problem. We implemented weaving in a managed plugin and we've noticed that Unity loads it pretty late (after already recompiling some assemblies). Because of this, we make the following call after the plugin loads:

    CompilationPipeline.RequestScriptCompilation(RequestScriptCompilationOptions.CleanBuildCache)

    This is very ineffective, for obvious reasons. How can we solve it?

    Ideally, the plugin needs to load before Unity decides to recompile any scripts - in that case hooking into CompilationPipeline.assemblyCompilationFinished should just work.