Create Visual Studio Solution 构建设置可生成 Visual Studio 解决方案而不是构建的应用程序。此选项仅在使用 Windows 构建目标时可用。
要启用 Create Visual Studio Solution,请转到 Edit > Build Settings > Target Platform,选择 Windows 构建目标,并启用 Create Visual Studio Solution 构建设置。然后选择 Build 以生成解决方案。
生成 Visual Studio 解决方案使您能够更改构建过程。例如,您可以:
警告:在重建 Unity 项目之前,请务必保存并备份在 Visual Studio 中所做的任何更改。如果不备份更改,Unity 会在构建过程中覆盖这些更改。
默认情况下,Unity 将生成的 Visual Studio 解决方案存储在与构建的项目相同的目录中。使用 Mono 脚本后端时,生成的解决方案包括三个项目,使用 IL2CPP 脚本后端时,生成的解决方案包括四个项目。
要切换为不同的脚本后端,对于 PC,请转到 Edit > Project Setting > Player > Settings for PC, Mac & Linux Standalone > Other Settings > Configuration,选择您的 Scripting Backend。
注意:只能在 Windows 计算机上构建 Windows IL2CPP。
下面是 Unity 为 Visual Studio 解决方案生成的项目的列表。
项目 | 描述 |
---|---|
projectName (表示您的项目名称) |
这是您的主项目。Visual Studio 将此项目构建到最终的应用程序可执行文件中。您最有可能在此处进行更改。 |
UnityData (存储在 projectName 项目内) |
此项目包含构建项目所需的所有 Unity 特定文件(如资源)。 |
UnityPlayerStub | 这是一个 UnityPlayer.dll 存根库。Unity 使用它将可执行文件链接到 UnityPlayer.dll 并公开可用的 UnityPlayer.dll API。 |
Il2CppOutputProject (仅限 IL2CPP 脚本后端) |
此项目包含: 生成的 C++ 代码,是 Unity 从托管程序集转换而来的。 * IL2CPP 运行时的源代码。 IL2CPP 垃圾回收器。 您可以从 Visual Studio 内部调试此代码。 |
Unity 生成面向 Visual Studio 2015 的 Visual Studio 解决方案。如果使用的是较新版本的 Visual Studio,打开 Visual Studio 解决方案时,可能会出现 Retarget Projects 对话框。
Retarget Projects 对话框提示您升级 Visual Studio 解决方案以匹配已安装的 Visual Studio 版本。选择 OK 接受此建议。
Visual Studio 提供多种构建配置选项。本节中的所有优化和调试参考仅指 Visual Studio 解决方案。
Configuration | 用法 | 描述 |
---|---|---|
Debug | 调试 C++ 代码时使用 Debug 配置。 | * 禁用所有优化。 * 保留代码中的所有调试信息。 * 导致代码运行缓慢。 |
Release | 使用 Release 配置来分析游戏。 | * 启用代码优化 |
Master | 使用 Master 配置进行游戏提交和最终测试。 | * 禁用性能分析器。 * 构建时间与 Release 配置相同。 |
MasterWithLTCG 仅在启用 IL2CPP 脚本后端时可用。 |
如果使用的是 IL2CPP 脚本后端,可以选择 Master 或 MasterWithLTCG 进行游戏提交和最终测试。 | * 为生成的 C++ 代码、IL2CPP 运行时和 IL2CPP 垃圾收集启用链接时间代码生成。 * 与 Master 配置相比,构建时间要长得多。 * 生成的应用程序执行得更快。 |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.