Reputation: 36
I have integrated VSCode with Unity 2017.3.0f3 by following the tutorial given in VSCode Docs
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.
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?
Upvotes: 2
Views: 2975
Reputation: 1099
In order to open a Unity file in an existing workspace, as of Unity 2022.3 I found you need to put -r -g $(File):$(Line):$(Column)
for the external script editor args. (The quotes around $(File)
in the default caused it to open a new file).
Upvotes: 0
Reputation: 71
For Linux users try edit vscode .desktop file:
In this line:
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/vscode_vscode.desktop /snap/bin/vscode
add "$@" at the end:
Exec=env BAMF_DESKTOP_FILE_HINT=/var/lib/snapd/desktop/applications/vscode_vscode.desktop /snap/bin/vscode "$@"
Upvotes: 0
Reputation: 9338
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
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
(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
-r -g "$(File)":$(Line)
That's it, I have verified this to work on my macOS 10.13.4 and Unity 2018.1
Upvotes: 2
Reputation: 125245
This is a bug which is not yet fixed on the Unity VSCode built-in extension. Read below for a possible fix.
I do not see the "External Script Editor Args" settings in *Preferences > External Tools" as described in the Unity Doc.
You won't see this if you use one of the build-in Editors displayed in that menu. Create your own.
You need to point External Script Editor to an exe file or a batch script in order for the "External Script Editor Args" settings to appear.
Create a batch. Name it vscode.bat. The code below should be inside of it:
"C:\Program Files\Microsoft VS Code\Code.exe" %*
exit 0
Note that C:\Program Files\Microsoft VS Code\Code.exe
is the path of your VSCode so make sure to substitute your own path there.
Go to Preferences > External Tools then select on Browse on the External Script Editor menu then select the vscode.bat.
When the File Browser pops up, change from "exe (*.exe)" to "*All files (*.*)"".
Select the vscode.bat file and click the Open button.
"External Script Editor Args" settings should now appear. Use "$(File)" in it. Include the " " too. This may also solve your multiple workspace problems in your question.
The final image should look this:
Upvotes: 2