在Unity中调试(c#) + Visual Studio代码在OS X上工作?

时间:2022-09-21 02:52:20

I really like the idea of working with Visual Studio, C# and Unity on OS X.

我非常喜欢在OS X上使用Visual Studio、c#和Unity。

Has anyone made debugging with C# in Unity work with Visual Studio Code on OS X?

有人在Unity中使用c#调试过OS X上的Visual Studio代码吗?

8 个解决方案

#1


3  

Hi the solution is https://github.com/dotBunny/VSCode This plugin works on both MacOS and Windows and gives you the following capabilities:

你好,解决方案是https://github.com/dotBunny/VSCode这个插件可以在MacOS和Windows上运行,并提供以下功能:

•An option to enable VS Code integration (Editor –> Assets –> Enable Integration), this updates your solution files and (more importantly) keeps them in sync. This also sets the preferred external tool editor in the Unity preferences. *Note, the old “Sync MonoDevelop” option is now gone in the Unity editor from V5.2

•支持VS代码集成的选项(编辑器- >资产- >支持集成),这将更新您的解决方案文件,(更重要的)使它们保持同步。这也在Unity首选项中设置首选的外部工具编辑器。*注意,以前的“Sync MonoDevelop”选项现在在V5.2的Unity编辑器中消失了

•It writes out the necessary (and sometimes hard to find) VS Code configuration files, including the ability to hide “non-code” files in the editor (hides things like .sln, .csproj and the ever present unity .meta files) There are a couple of other settings in there to help speed up the integration.

•它写出必要的(有时是很难找到)VS代码配置文件,包括隐藏的能力“非代码”文件在编辑器中(隐藏. sln,.csproj和团结.meta文件)有一些其他设置在那里帮助加速整合。

•Automatically launches VS Code direct to your project folder, EVERY-TIME. no longer do you have to worry about keeping that window open, or switching around if you work on multiple projects

每次自动启动VS代码直接到你的项目文件夹。你不再需要担心打开窗口,或者在多个项目中切换

One thing to be aware of, once you enable the VSCode integration, changing your preferred code editor in the External Tools preferences will have no effect as the plugin takes over opening code files. If you want to use another editor, you’ll have to disable the integration first.

需要注意的一件事是,一旦启用了VSCode集成,在外部工具首选项中更改首选代码编辑器将不起作用,因为插件将接管打开代码文件。如果您想使用另一个编辑器,您必须首先禁用集成。

在Unity中调试(c#) + Visual Studio代码在OS X上工作?

These are just the main highlights as there are more features in there as well.

这些只是主要的亮点,因为还有更多的特性。

Currently you need to download the plugin files from GitHub

目前您需要从GitHub上下载插件文件

#2


7  

Yes it works absolutely fine. Unity is C#, JavaScript or Boo. So, you don't need .NET for it. Unity uses Mono runtime. So, an existing VS project can be opened in Unity for Mac OS X.

是的,它非常有效。Unity是c#、JavaScript或Boo。所以,你不需要。net。统一使用Mono运行时。因此,现有的VS项目可以在Mac OS X的Unity中打开。

EDIT

Here is a link that helps you to attach a debugger to the VS endpoint. http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/

这里有一个链接,可以帮助您将调试器附加到VS端点。http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/

You can try VS Tools for Unity too. http://unityvs.com

你也可以尝试VS工具的统一。http://unityvs.com

UPDATE

There is this awesome Unity Plugin by dotBunny that solves the problem and integrates Code with Unity tools.

dotBunny有一个很棒的Unity插件,它解决了这个问题,并将代码与Unity工具集成在一起。

#3


5  

An existing Visual Studio solution can be build and debugged with Visual Studio Code on the Mac with Mono. You have to use the launch.json and tasks.json files. I described it on my blog: Compile and Debug

现有的Visual Studio解决方案可以使用Mono在Mac上的Visual Studio代码构建和调试。你必须使用发射。json和任务。json文件。我在我的博客上描述了它:编译和调试

在Unity中调试(c#) + Visual Studio代码在OS X上工作?

#4


1  

To build Unity in Visual Studio Code, you can hook up Mono xbuild compiler as a task runner, so you don't even have to leave IDE to have errors and warnings.

要在Visual Studio代码中构建Unity,您可以将Mono xbuild编译器连接为一个任务运行器,因此您甚至不必让IDE产生错误和警告。

See https://twitter.com/_eppz/status/846859856787259392 for more.

见https://twitter.com/_eppz/status/846859856787259392。

#5


0  

It's a little unstable. But it's possible from recent VSC version.

有点不稳定。但从最近的VSC版本来看,这是可能的。

1) Install this VSC Unity plugin-in. https://github.com/dotBunny/VSCode/

1)安装这个VSC Unity插件。https://github.com/dotBunny/VSCode/

2) Follow these commands. (Step 1, 2 and 3) https://code.visualstudio.com/Docs/runtimes/unity

2)遵循这些命令。(步骤1、2和3)https://code.visualstudio.com/Docs/runtimes/unity

3) After you complete the settings, launch the VSC using Unity menu.

3)完成设置后,使用Unity菜单启动VSC。

Assets/Open C# Project in Code

4) Play the Unity project. You can see the debug port number on the unity console. And the project's launch.json file will be renewed automatically.

4)开展团结项目。您可以在unity控制台上看到调试端口号。和项目的启动。json文件将自动更新。

To open launch.json, click option icons. 在Unity中调试(c#) + Visual Studio代码在OS X上工作?
the file exists in this folder.

打开启动。json,点击选择图标。该文件存在于此文件夹中。

.vscode/launch.json

sample.

样本。

{
    "version":"0.1.0",
    "configurations":[ 
        {
            "name":"Unity",
            "type":"mono",
            "address":"localhost",
            "port":56621
        }
    ]
}

5) Start debug in VSC debug tab.

5)在VSC调试选项卡中启动调试。

That's it. Hope this help.

就是这样。希望这个有帮助。

#6


0  

[Feb 2017] It is now possible to do this without the dotBunny plugin.

[2017年2月]现在不需要dotBunny插件就可以实现。

i.e. Support is built into Unity natively.

也就是说,支持本身就是统一的。

Just to repeat, you don't need to fiddle with Unity, just VSCode.

重复一遍,不需要修改Unity,只需要VSCode。

Instructions here

说明在这里

Instructions are incomplete though, and I didn't take screenshots (please do!), but basically what I did was:

虽然指导是不完整的,而且我没有截屏(请这样做!),但基本上我所做的是:

(...and please improve these instructions as you go, I'm working from memory...)

(…请在你离开时改进这些说明,我是在记忆中工作……

  1. I deleted/renamed my .vscode/Launch.json file, as per the link.
  2. 我删除/重命名.vscode /发射。json文件,根据链接。
  3. Double-click on some file to bring up the project in VSCode (maybe first make sure that in Unity's settings you have selected VSCode as your default code editor)
  4. 双击某个文件,在VSCode中打开项目(可能首先要确保在Unity的设置中,您已经选择了VSCode作为默认的代码编辑器)
  5. clicking the bug icon then the cogwheel, as per the link.
  6. 单击bug图标,然后按链接单击cogwheel。
  7. I had to install that vscode-unity-debug plugin in VSCode, just filtering the search with 'unity' found it.
  8. 我不得不在VSCode中安装VSCode - un爱德华-调试插件,只是用“unity”搜索。
  9. I then had to press the green 'play' triangle.
  10. 然后我不得不按下绿色的“play”三角形。
  11. I set a breakpoint in my code.
  12. 我在代码中设置了一个断点。
  13. Now over to unity and press play, and the breakpoint gets hit.
  14. 现在切换到unity并按play,断点会被命中。

#7


0  

The Unity Debugger for Visual Studio Code is working, but doesn't work well enough when doing any kind of serious work for now. I really hope they will improve it in the future as I prefer VS Code over VS.

Visual Studio代码的Unity调试器正在工作,但是现在在做任何严肃的工作时都不能很好地工作。我真的希望他们将来能改进它,因为我更喜欢VS代码而不是VS。

Current problems I encountered -Sometimes I cannot step in a function, the debugger will hang until you detach -no local variable, you have to watch everything -some more complex variable have no support, so you can't see what is inside -A bit overall unstable with unexpected behaviours.

我遇到的当前问题-有时我不能进入一个函数,调试器会挂起直到你分离-没有局部变量,你必须观察所有的东西-一些更复杂的变量没有支持,所以你不能看到里面是什么- - -一个整体上不稳定的,有意想不到的行为。

What I love about it, Attaching & Detaching is a breeze. Just press a button, allowing to attach and detach quickly as needed. e.g. At the beginning of the program I work on, there will be an bunch of exception. I can detach and attach quickly to skip the exceptions.

我喜欢它,依恋和分离是微风。只需按下一个按钮,就可以根据需要迅速地连接和分离。在我工作的项目开始时,会有很多例外。我可以快速地分离和附加,以跳过异常。

The problems with it are too constraining as it currently stands, I had to go back to the classic Visual Studio.

它目前的问题太局限了,我不得不回到经典的Visual Studio。

#8


-1  

Update, 2016 - the petition was popular enough that some VS Code extensions have been written for it: https://marketplace.visualstudio.com/search?term=unity&target=VSCode&sortBy=Relevance

2016年更新——这份请愿书非常受欢迎,一些VS代码扩展已经为它写好了:https://marketplace.visualstudio.com/search?


Petition for it on the Visual Studio UserVoice page: http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7752702-unity-integration

在Visual Studio UserVoice页面上为它请愿:http://visualstudio.uservoice.com/forums/293070- Visual - Studio - code/tions/7752702 -统一集成

#1


3  

Hi the solution is https://github.com/dotBunny/VSCode This plugin works on both MacOS and Windows and gives you the following capabilities:

你好,解决方案是https://github.com/dotBunny/VSCode这个插件可以在MacOS和Windows上运行,并提供以下功能:

•An option to enable VS Code integration (Editor –> Assets –> Enable Integration), this updates your solution files and (more importantly) keeps them in sync. This also sets the preferred external tool editor in the Unity preferences. *Note, the old “Sync MonoDevelop” option is now gone in the Unity editor from V5.2

•支持VS代码集成的选项(编辑器- >资产- >支持集成),这将更新您的解决方案文件,(更重要的)使它们保持同步。这也在Unity首选项中设置首选的外部工具编辑器。*注意,以前的“Sync MonoDevelop”选项现在在V5.2的Unity编辑器中消失了

•It writes out the necessary (and sometimes hard to find) VS Code configuration files, including the ability to hide “non-code” files in the editor (hides things like .sln, .csproj and the ever present unity .meta files) There are a couple of other settings in there to help speed up the integration.

•它写出必要的(有时是很难找到)VS代码配置文件,包括隐藏的能力“非代码”文件在编辑器中(隐藏. sln,.csproj和团结.meta文件)有一些其他设置在那里帮助加速整合。

•Automatically launches VS Code direct to your project folder, EVERY-TIME. no longer do you have to worry about keeping that window open, or switching around if you work on multiple projects

每次自动启动VS代码直接到你的项目文件夹。你不再需要担心打开窗口,或者在多个项目中切换

One thing to be aware of, once you enable the VSCode integration, changing your preferred code editor in the External Tools preferences will have no effect as the plugin takes over opening code files. If you want to use another editor, you’ll have to disable the integration first.

需要注意的一件事是,一旦启用了VSCode集成,在外部工具首选项中更改首选代码编辑器将不起作用,因为插件将接管打开代码文件。如果您想使用另一个编辑器,您必须首先禁用集成。

在Unity中调试(c#) + Visual Studio代码在OS X上工作?

These are just the main highlights as there are more features in there as well.

这些只是主要的亮点,因为还有更多的特性。

Currently you need to download the plugin files from GitHub

目前您需要从GitHub上下载插件文件

#2


7  

Yes it works absolutely fine. Unity is C#, JavaScript or Boo. So, you don't need .NET for it. Unity uses Mono runtime. So, an existing VS project can be opened in Unity for Mac OS X.

是的,它非常有效。Unity是c#、JavaScript或Boo。所以,你不需要。net。统一使用Mono运行时。因此,现有的VS项目可以在Mac OS X的Unity中打开。

EDIT

Here is a link that helps you to attach a debugger to the VS endpoint. http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/

这里有一个链接,可以帮助您将调试器附加到VS端点。http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/

You can try VS Tools for Unity too. http://unityvs.com

你也可以尝试VS工具的统一。http://unityvs.com

UPDATE

There is this awesome Unity Plugin by dotBunny that solves the problem and integrates Code with Unity tools.

dotBunny有一个很棒的Unity插件,它解决了这个问题,并将代码与Unity工具集成在一起。

#3


5  

An existing Visual Studio solution can be build and debugged with Visual Studio Code on the Mac with Mono. You have to use the launch.json and tasks.json files. I described it on my blog: Compile and Debug

现有的Visual Studio解决方案可以使用Mono在Mac上的Visual Studio代码构建和调试。你必须使用发射。json和任务。json文件。我在我的博客上描述了它:编译和调试

在Unity中调试(c#) + Visual Studio代码在OS X上工作?

#4


1  

To build Unity in Visual Studio Code, you can hook up Mono xbuild compiler as a task runner, so you don't even have to leave IDE to have errors and warnings.

要在Visual Studio代码中构建Unity,您可以将Mono xbuild编译器连接为一个任务运行器,因此您甚至不必让IDE产生错误和警告。

See https://twitter.com/_eppz/status/846859856787259392 for more.

见https://twitter.com/_eppz/status/846859856787259392。

#5


0  

It's a little unstable. But it's possible from recent VSC version.

有点不稳定。但从最近的VSC版本来看,这是可能的。

1) Install this VSC Unity plugin-in. https://github.com/dotBunny/VSCode/

1)安装这个VSC Unity插件。https://github.com/dotBunny/VSCode/

2) Follow these commands. (Step 1, 2 and 3) https://code.visualstudio.com/Docs/runtimes/unity

2)遵循这些命令。(步骤1、2和3)https://code.visualstudio.com/Docs/runtimes/unity

3) After you complete the settings, launch the VSC using Unity menu.

3)完成设置后,使用Unity菜单启动VSC。

Assets/Open C# Project in Code

4) Play the Unity project. You can see the debug port number on the unity console. And the project's launch.json file will be renewed automatically.

4)开展团结项目。您可以在unity控制台上看到调试端口号。和项目的启动。json文件将自动更新。

To open launch.json, click option icons. 在Unity中调试(c#) + Visual Studio代码在OS X上工作?
the file exists in this folder.

打开启动。json,点击选择图标。该文件存在于此文件夹中。

.vscode/launch.json

sample.

样本。

{
    "version":"0.1.0",
    "configurations":[ 
        {
            "name":"Unity",
            "type":"mono",
            "address":"localhost",
            "port":56621
        }
    ]
}

5) Start debug in VSC debug tab.

5)在VSC调试选项卡中启动调试。

That's it. Hope this help.

就是这样。希望这个有帮助。

#6


0  

[Feb 2017] It is now possible to do this without the dotBunny plugin.

[2017年2月]现在不需要dotBunny插件就可以实现。

i.e. Support is built into Unity natively.

也就是说,支持本身就是统一的。

Just to repeat, you don't need to fiddle with Unity, just VSCode.

重复一遍,不需要修改Unity,只需要VSCode。

Instructions here

说明在这里

Instructions are incomplete though, and I didn't take screenshots (please do!), but basically what I did was:

虽然指导是不完整的,而且我没有截屏(请这样做!),但基本上我所做的是:

(...and please improve these instructions as you go, I'm working from memory...)

(…请在你离开时改进这些说明,我是在记忆中工作……

  1. I deleted/renamed my .vscode/Launch.json file, as per the link.
  2. 我删除/重命名.vscode /发射。json文件,根据链接。
  3. Double-click on some file to bring up the project in VSCode (maybe first make sure that in Unity's settings you have selected VSCode as your default code editor)
  4. 双击某个文件,在VSCode中打开项目(可能首先要确保在Unity的设置中,您已经选择了VSCode作为默认的代码编辑器)
  5. clicking the bug icon then the cogwheel, as per the link.
  6. 单击bug图标,然后按链接单击cogwheel。
  7. I had to install that vscode-unity-debug plugin in VSCode, just filtering the search with 'unity' found it.
  8. 我不得不在VSCode中安装VSCode - un爱德华-调试插件,只是用“unity”搜索。
  9. I then had to press the green 'play' triangle.
  10. 然后我不得不按下绿色的“play”三角形。
  11. I set a breakpoint in my code.
  12. 我在代码中设置了一个断点。
  13. Now over to unity and press play, and the breakpoint gets hit.
  14. 现在切换到unity并按play,断点会被命中。

#7


0  

The Unity Debugger for Visual Studio Code is working, but doesn't work well enough when doing any kind of serious work for now. I really hope they will improve it in the future as I prefer VS Code over VS.

Visual Studio代码的Unity调试器正在工作,但是现在在做任何严肃的工作时都不能很好地工作。我真的希望他们将来能改进它,因为我更喜欢VS代码而不是VS。

Current problems I encountered -Sometimes I cannot step in a function, the debugger will hang until you detach -no local variable, you have to watch everything -some more complex variable have no support, so you can't see what is inside -A bit overall unstable with unexpected behaviours.

我遇到的当前问题-有时我不能进入一个函数,调试器会挂起直到你分离-没有局部变量,你必须观察所有的东西-一些更复杂的变量没有支持,所以你不能看到里面是什么- - -一个整体上不稳定的,有意想不到的行为。

What I love about it, Attaching & Detaching is a breeze. Just press a button, allowing to attach and detach quickly as needed. e.g. At the beginning of the program I work on, there will be an bunch of exception. I can detach and attach quickly to skip the exceptions.

我喜欢它,依恋和分离是微风。只需按下一个按钮,就可以根据需要迅速地连接和分离。在我工作的项目开始时,会有很多例外。我可以快速地分离和附加,以跳过异常。

The problems with it are too constraining as it currently stands, I had to go back to the classic Visual Studio.

它目前的问题太局限了,我不得不回到经典的Visual Studio。

#8


-1  

Update, 2016 - the petition was popular enough that some VS Code extensions have been written for it: https://marketplace.visualstudio.com/search?term=unity&target=VSCode&sortBy=Relevance

2016年更新——这份请愿书非常受欢迎,一些VS代码扩展已经为它写好了:https://marketplace.visualstudio.com/search?


Petition for it on the Visual Studio UserVoice page: http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7752702-unity-integration

在Visual Studio UserVoice页面上为它请愿:http://visualstudio.uservoice.com/forums/293070- Visual - Studio - code/tions/7752702 -统一集成