With Unity integration enabled, it seems I am not able to open a file without VS code existing current custom workspace (which usually include multiple root folders).
I can understand why Unity ask VS Code to switch workspace, but it’s not what I want. Is there a workaround for this?
It’s possible using custom command arguments.
Go to Preferences then External Tools and change the field External script editor args to -g “(File):(Line)”.
When Visual studio code is selected, this field is hidden. As a workaround you can create a vscode.bat (Windows) that launch your visual studio code executable (more at visual studio code - Unity opens multiple workspaces when using VSCode as editor - Stack Overflow).
If like me you don’t want to see a command terminal launch in the background each time you open a script, you can create an executable version of your batch file with Slimm Bat to Exe (https://download.cnet.com/Slimm-Bat-to-Exe/3000-2216_4-75834541.html?part=dl-&subj=dl&tag=button)
Attached a zip with the vscode.bat pointing to my vscode path and the resulting executable with a tiny icon.
Of course if your installation directory is different you should change it in the batch file and then recreate the executable.
I hope that helps,
3948463–338014–VScode.zip (30.4 KB)
1 Like
Thanks,
helped me!
But i edited the script editor args to: -g (ProjectPath) "(File):$(Line)" this way the vs code open with project open. obs: for some reason i had change my target framework from 4.7.1 to 4.6.1