当前位置:   article > 正文

Unity编译器中重编译脚本_unity 重新编译

unity 重新编译

Unity编译器中重编译脚本(清除Unity项目缓存)

文件需要放置到Unity工程中的Editor目录下

文件名 CompilationWindow.cs

public class CompilationWindow : EditorWindow
{
    [MenuItem("Window/Pump Editor/Compilation")]
    private static void ShowWindow()
    {
        var window = GetWindow<CompilationWindow>();
        window.titleContent = new GUIContent("CompilationWindow");
        window.Show();
    }

    private void OnGUI()
    {
        if (GUILayout.Button("Request Script Compilation"))
        {
#if UNITY_2019_3_OR_NEWER
            CompilationPipeline.RequestScriptCompilation();
#elif UNITY_2017_1_OR_NEWER
            var editorAssembly = System.Reflection.Assembly.GetAssembly(typeof(Editor));
            var editorCompilationInterfaceType = editorAssembly.GetType("UnityEditor.Scripting.ScriptCompilation.EditorCompilationInterfaceType");
            var dirtyAllScriptMethod = editorCompilationInterfaceType.GetMethod("DirtyAllScripts", BindingFlags.Static | BindingFlags.Public);
            dirtyAllScriptMethod?.Invoke(editorCompilationInterfaceType, null);
#endif
        }
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/111948
推荐阅读
相关标签
  

闽ICP备14008679号