C# 使用 Unity3D 和 Visual Studio 2013
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19889848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Working with Unity3D and Visual Studio 2013
提问by Kaoru
how do i get Unity3D for debugging the code, and Visual Studio 2013 which i have now to only script the code. Example: Like Flash Professional for debugging and FlashDevelop for scripting only.
我如何获得用于调试代码的 Unity3D,以及我现在只需要编写代码脚本的 Visual Studio 2013。示例:像用于调试的 Flash Professional 和仅用于脚本的 FlashDevelop。
My question is, how do i get the Unity3D link with Visual Studio 2013. I already searching around the internet, and had found that Unity3D only works with VisualStudio 2010.
我的问题是,如何获得 Visual Studio 2013 的 Unity3D 链接。我已经在互联网上搜索,发现 Unity3D 仅适用于 VisualStudio 2010。
回答by strobe
you can use unityvs VS plugin (but I'm not sure about current 2013 support, it's works with vs2012) http://unityvs.com/- on windows it's works very well, but remote OSX debugging feature is not ready yet
您可以使用 unityvs VS 插件(但我不确定当前的 2013 支持,它适用于 vs2012)http://unityvs.com/- 在 Windows 上它运行良好,但远程 OSX 调试功能尚未准备就绪
回答by S.Richmond
I wrote a blog article on this awhile back on my blog HEREfor Visual Studio.
不久前,我在 Visual Studio 的博客 HERE上写了一篇关于此的博客文章。
However I will paste it here too:
不过我也会把它贴在这里:
How to use Visual Studio 2013
如何使用 Visual Studio 2013
- Recently Microsoft bought and re-released the popular Unity3D plugin UnityVS. The now renamed Visual Studio Tools for Unity plugin smooths the connection between Unity and Visual Studio and even allows one to perform debugging too! Download it here.
- In Unity Editor go to Edit->Preferences->External Tools and In External Script Editor choose Browse from the drop down box.
- Browse to and select C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.
- The External Script Editor should automatically show your selected editor as Visual Studio 2013.
- That's it! It should just work from that point on.
- 最近微软购买并重新发布了流行的 Unity3D 插件 UnityVS。现在重命名的 Visual Studio Tools for Unity 插件平滑了 Unity 和 Visual Studio 之间的连接,甚至还允许执行调试!在这里下载。
- 在 Unity Editor 中,转到 Edit->Preferences->External Tools,然后在 External Script Editor 中从下拉框中选择 Browse。
- 浏览并选择 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe。
- 外部脚本编辑器应自动将您选择的编辑器显示为 Visual Studio 2013。
- 就是这样!从那时起它应该可以正常工作。
回答by dev-masih
With Visual Studio You Can Use UnityVS Plugin But if You Use Monodevelop You Can Go To Run->Attach To Process.. And Connect The Debugger to Unity Editor It Work Perfectly.
使用 Visual Studio,您可以使用 UnityVS 插件,但是如果您使用 Monodevelop,您可以转到运行->附加到进程..并将调试器连接到 Unity 编辑器,它完美地工作。
回答by Gurgadurgen
None of these solutions worked for me. Renaming monodevelop just changed the default program to notepad++, and the next default program after that was simply notepad.
这些解决方案都不适合我。重命名monodevelop只是将默认程序更改为notepad++,之后的下一个默认程序只是记事本。
However, there is a known bug with Visual Studio 2013 (not sure if it was present in previous versions, or if it is present in the non-professional version) where if you try to open a C# file in visual studio, where Visual Studio is opened as administrator and Unity isn't, VS crashes.
但是,Visual Studio 2013 存在一个已知错误(不确定它是否存在于以前的版本中,或者是否存在于非专业版本中),如果您尝试在 Visual Studio 中打开 C# 文件,其中 Visual Studio以管理员身份打开而 Unity 未打开,VS 崩溃。
I had to either run both programs (VS and Unity) as administrator, or not open VS as administrator (as per the solution found here: http://connect.microsoft.com/VisualStudio/feedback/details/597863/cannot-open-visual-studio-files-from-windows-explorer).
我必须以管理员身份运行两个程序(VS 和 Unity),或者不以管理员身份打开 VS(根据此处找到的解决方案:http: //connect.microsoft.com/VisualStudio/feedback/details/597863/cannot-open -visual-studio-files-from-windows-explorer)。
回答by Petr Abdulin
As an important update, I would like to notice, that former UnityVS (after Microsoft's acquisition of SyntaxTree) is now available for free as a rebranded Visual Studio 2013 Tools for Unity.
作为一个重要的更新,我想指出,以前的 UnityVS(在 Microsoft 收购 SyntaxTree 之后)现在可以作为重新命名的Visual Studio 2013 Tools for Unity 免费提供。
回答by Pietro Polsinelli
The integration of Unity3d and Visual Studio got simpler with latest Unity (version 5) and Visual Studio Tools. This is the current procedure.
使用最新的 Unity(版本 5)和 Visual Studio 工具,Unity3d 和 Visual Studio 的集成变得更加简单。这是当前的程序。
To use Visual Studio as editor and debugger with Unity you must:
要将 Visual Studio 用作 Unity 的编辑器和调试器,您必须:
Install the Visual Studio Tools For Unity. For this download the package at http://unityvs.com(careful to get the version for the Visual Studio you are using) and import it (as is standard in Unity for packages) by going into Assets -> Import Package -> Custom Packageand browse to the tools installation folder and pick the package.
Once installed in Unity you will get an additional menu Visual Studio Tools, go there and select "generate project files". Visual Studio will already be the default editor for your scripts.
This done, if you say put a breakpoint in Visual Studio, click on "Attach to Unity" in Visual Studio, and then run your Unity project, the process will stop at breakpoints in Visual Studio and allow variable inspection etc.
安装适用于 Unity 的 Visual Studio 工具。为此,请在http://unityvs.com下载包(小心获取您正在使用的 Visual Studio 的版本)并通过进入Assets -> Import Package -> Custom导入它(这是 Unity 中的包的标准)打包并浏览到工具安装文件夹并选择包。
在 Unity 中安装后,您将获得一个附加菜单Visual Studio Tools,转到那里并选择“生成项目文件”。Visual Studio 已经是脚本的默认编辑器。
完成后,如果您说在 Visual Studio 中放置一个断点,在 Visual Studio 中单击“附加到 Unity”,然后运行您的 Unity 项目,该过程将在 Visual Studio 中的断点处停止并允许进行变量检查等。
回答by Jeff Mlakar
I'd like to add to the fine answer given by Pietro Polsinelli, that for me, there was an extra step in his Step 1. And that is that, after installing Visual Studio Tools For Unity, I had to, in Unity, go to Assets->Import Package->Visual Studio 201X Tools and then click around on the menu bar until "Visual Studio Tools" showed up as an option. After that, I could Generate Project Files and Open in Visual Studio.
我想补充 Pietro Polsinelli 给出的很好的答案,对我来说,他的第 1 步中有一个额外的步骤。也就是说,在安装 Visual Studio Tools For Unity 之后,我必须在 Unity 中到 Assets->Import Package->Visual Studio 201X Tools 然后在菜单栏上单击,直到“Visual Studio Tools”显示为一个选项。之后,我可以生成项目文件并在 Visual Studio 中打开。
This enabled me to Attach to Unity in Visual Studio and debug.
这使我能够在 Visual Studio 中附加到 Unity 并进行调试。