Version: 2022.1

CompilationPipeline.RequestScriptCompilation

切换到手册
public static void RequestScriptCompilation ();
public static void RequestScriptCompilation (Compilation.RequestScriptCompilationOptions options);

参数

options Optional parameter to specify whether the Editor should clear the build cache before compilation.

描述

Allows you to request that the Editor recompile scripts in the project.

When you call this method, the Unity Editor checks whether there have been any changes to scripts, or to settings affecting script compilation, and recompiles those scripts which require it. After the compilation, if the compilation was successful, the Unity Editor reloads all assemblies. If you want to force recompilation of all scripts, even if there are no changes, you can pass RequestScriptCompilationOptions.CleanBuildCache for the options parameter. You may want to force recompilation of all scripts in the following situations: - If you have a successful compilation, but want to see all compiler warnings again. - If you have a setup where the compilation pipeline takes input from files that Unity cannot track (this is possible in rare circumstances when using response files). - If there is a bug or suspected bug in the compilation pipeline causing it to not pick up changes.