一种更完善的 C# 开发环境。 智能自动补齐、基于计算机辅助的源文件更改、智能语法突出显示等。
VisualStudio C# 是 Microsoft 推出的集成开发环境 (IDE) 工具。 Visual Studio 现在有三个版本:Community(免费使用)、Professional(付费)和 Enterprise(付费)。Visual Studio 网站上提供了版本之间功能差异的比较。
通过在 Unity 中集成 Visual Studio,可以自动创建和维护 Visual Studio 项目文件。此外,在双击脚本或 Unity 控制台中的错误消息时,VisualStudio 将会打开。
请按照以下步骤配置 Unity Editor 以便将 Visual Studio 用作其默认 IDE:
在 Unity 中,选择 __Edit > Preferences__,并确保选择 Visual Studio 作为首选的外部编辑器。
接下来,双击项目中的 C# 文件。Visual Studio 应该会自动打开该文件。
可以编辑文件、保存文件并切换回 Unity 来测试更改。
尽管 Visual Studio 附带了自己的 C# 编译器,并且您可以使用它来检查 # 脚本中是否存在错误,但 Unity 仍然使用自己的 C# 编译器来编译脚本。使用 Visual Studio 编译器仍然非常有用,因为这意味着不必一直切换到 Unity 来检查是否有任何错误。
Visual Studio 的 C# 编译器比 Unity 的 C# 编译器目前支持的功能更多。也就是说,某些代码(尤其是较新的 # 功能)不会在 Visual Studio 中抛出错误,但在 Unity 中则会。
Unity 会自动创建和维护 Visual Studio .sln 和 .csproj 文件。每当在 Unity 中添加/重命名/移动/删除文件时,Unity 都会重新生成 .sln 和 .csproj 文件。也可以从 Visual Studio 向解决方案添加文件。Unity 随后会导入这些新文件,下次 Unity 再次创建项目文件时,便会使用包含的新文件进行创建。
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.