使用VSCode作为编辑器时Unity打开多个工作区 [英] Unity opens multiple workspaces when using VSCode as editor
问题描述
我已按照VSCode 文档中给出的教程,将VSCode与Unity 2017.3.0f3集成. a>
I have integrated VSCode with Unity 2017.3.0f3 by following the tutorial given in VSCode Docs
我面临的一个问题是,每当我从Unity项目资源管理器中打开脚本文件时,它都会在VSCode中打开多个工作区.此外,如果单击资产>打开C#项目,则下次我双击打开文件时,打开的工作区数量会增加.
I am facing an issue wherein whenever I open a script file from the Unity project explorer, it opens multiple workspace in VSCode. Furthermore, if click Assets > Open C# Project, then the number of opened workspace increases the next time I double click to open a file.
此外,我没有在Unity 外部工具"中看到外部脚本编辑器Args"设置. rel ="nofollow noreferrer">文档.
Also, I do not see the "External Script Editor Args" settings in *Preferences > External Tools" as described in the Unity Doc.
有人解决了这个问题吗?
Has anybody fixed this issue?
推荐答案
我试图在macOS上做同样的事情,这比Windows解决方案@Programmer发布的要复杂得多,为完整性起见,我在这里添加了它.
I was trying to do the same on macOS, which is a bit more elaborate than the Windows solution @Programmer posted, I am adding it here for completeness sake.
- 使用这些行创建一个
test.sh
文件(当然,请确保您的VSCode位于此位置)
- Create a
test.sh
file with these lines (of course, make sure your VSCode is at this location)
nano test.sh
#!/bin/bash
"/Applications/Visual Studio Code.app/Contents/Resources/app/bin/code" "$@"
- 现在获得此方便的脚本,该脚本可以从您的
test.sh
创建一个最小的应用程序(需要执行此步骤,因为macOS上的Unity不允许您选择除.app
文件以外的任何内容作为外部编辑器,这与其他工具不同Windows)
- Now get this handy script, which can create a minimal app from your
test.sh
(this step is needed because Unity on macOS doesn't allow you to select anything other than an.app
file as the external editor, unlike Windows)
https://gist.github.com/mathiasbynens/674099
./applify test.sh "Test"
- 创建您的应用后,请在终端中尝试以下操作,以确保它可以正常工作:
Test.app/Contents/MacOS/Test -r -g /path-to-some-file:10
- 如果有效,则可以将其设置为Unity中的外部编辑器,并将外部脚本编辑器Args 字段设置为:
- If it works, then you can set it as an external editor in Unity, and set External Script Editor Args field to:
-r -g "$(File)":$(Line)
- 双击Unity项目中的任何脚本和着色器,它应该可以工作.
就是这样,我已经验证了它可以在我的macOS 10.13.4和Unity 2018.1上正常工作.
这篇关于使用VSCode作为编辑器时Unity打开多个工作区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!