[2018年6月15日] Unity 3D 如何安装C# 7.x+ 环境

C#7.3支持Unity 2017.2+

测试平台

  • Unity 2017.4.3f1, 2018.1.0f2

  • Windows 10 x64 (editor + mono and il2cpp builds)

  • macOS 10.12 (editor + mono build)

  • Android 7.1.1 (mono and il2cpp builds)

  • Visual Studio 2017 15.8.0 Preview 1.1


1- 下载并安装Unity 2018.1 BETA 12

编译器能与Unity的早期版本的2018 Beta版本一起工作,但是如果没有B12,您将无法调试代码。


2- 将其添加到 manifest 文件中

Code (JavaScript):
  1. {
  2.      "dependencies" :  {
  3.          "com.unity.incrementalcompiler" :  "0.0.30"
  4.      } ,
  5.      "registry" :  "https://staging-packages.unity.com"
  6. }


3- 在项目的 player settings 中将您的脚本运行时设置为版本4.x , Unity加载的编译器客户端需要这个。


4- 删除您的项目的Library / ScriptAssemblies文件夹


这将删除由内置编译器编译的最后一个程序集,并确保新编译器以新的完全重新编译开始。

5- 从首选项窗口配置 Compiler 

一个新的“Compiler”部分被添加到Unity首选项窗口中。 您可以从那里控制一些编译器设置。


如何安装

  1. 从下载页面下载 CSharpVNextSupport 4.1.0。                                                                                                                  

  2. 将 CSharp70Support 文件夹从存档中解压缩到 Unity 项目的根目录中。 它应该放置在 Assets 文件夹旁边,而不是放在里面。                                                                                                                                                                                                                                    

  3. 将 CSharp70Support/CSharpVNextSupport.unitypackage 导入到项目中。                                                                                                                  

  4. 如果此时看到任何编译错误,请重新启动编辑器或运行全部重新导入。                                                                                                                  

  5. 删除项目文件夹中的所有 .csproj 文件以强制Unity重新创建它们。                                                                                                                  

  6. [可选]在Windows上,使用管理员权限运行一次 CSharp70Support / ngen install.cmd。 它将使用Ngen预编译csc.exepdb2mdb.exe。 它将削减每个C#项目几秒钟的编译时间。


原文:https://bitbucket.org/alexzzzz/unity-c-5.0-and-6.0-integration/src/831269ba3a61?at=default

猜你喜欢

转载自blog.csdn.net/qq_26486685/article/details/80710214