如何使用 Visual Studio 2012 调试我的统一项目?

How can I debug my unity project using Visual Studio 2012?

1) 我将首选项设置为使用 Visual Studio 2012

打开 Unity .cs 文件

2) 我遇到了这个:https://visualstudiogallery.msdn.microsoft.com/7ab11d2a-f413-4ed6-b3de-ff1d05157714

我下载并安装了适用于 Unity 的 VS2012 工具

3) 现在我被困在这里,当我尝试 run/debug VS 中的单个 .cs 文件时,出现此异常:

"A project with an Output Type of Class Library cannot be started directly. In order to debug this project,add an executable project to this solution which references the library project. Set the executable project as a startup project."

我不确定这意味着什么以及如何进行。我不确定如何将 Unity 与 Visual Studio.

同步

有人吗?

顺便说一句,我安装了 Unity 免费版 4.6.1 和 Visual Studio Premium 2012。

谢谢

http://unityvs.com/

为您的 VS 版本安装正确的版本后,您需要打开您的统一项目(在 unity 中)并添加 VS 工具包...

资源 > 导入包 > unity 20xx 的工具

然后您需要在...中设置您的默认编辑器

编辑 > 首选项 > 外部工具

然后,当您在 unity 中单击脚本时,它应该会在 VS 中打开它们。

现在,在 VS 中,您应该可以选择将统一调试器附加到工具栏中通常显示 "debug" 的位置。

将调试器附加到 unity 后 运行 你的游戏通过在 unity 中点击播放,它应该会遇到你在 VS 中设置的任何断点。

一切都应该神奇地工作。

关闭 visual studio 和 Unity。

下载并安装 Tools for unity 2012 以及指向其他版本的链接可在此处找到: https://visualstudiogallery.msdn.microsoft.com/7ab11d2a-f413-4ed6-b3de-ff1d05157714

打开Unity 3d

然后就像Wardy说的:

  1. 资产 > 导入包,Select "Tools for unity 2012"
  2. 编辑 > 首选项 > 外部工具,select 2012

我在使用 unity 2018 和 visual Studio 2017 时遇到了同样的错误消息。坦率地说,关闭 VS 并在双击一个 unity 脚本(在 unity 内部)后打开它解决了这个问题。