Not sure what could be happening. The C# extension is installed, and mono too. I’ve followed the steps indicated here too: Visual Studio Code and Unity but I can’t get it to work properly.
I’ve found that the issue might be that Unity isn’t generating .sln files, which VSCode seem to need in order for the imports to work. Any idea about why those files aren’t being generated?
I’ve found a workaround to generate the .sln files.
go to Edit → Preferences, then select the External tools tab
Ignore all advice given on other threads where you create an alias or a symbolic link to add custom arguments. Instead of that, in the External Script Editor field, select /usr/bin/code
If you selected the correct executable, there shouldn’t be any External Script Editor Args field.
if you try to open any script from unity now, it will still won’t work. Code files won’t be generated, and only the script will be opened in code, instead of the folder. Don’t worry.
Go to Assets → Open C# Project. Now code will open the project folder, the .stl files and other meaningful files will be generated (like the .vscode folder), and Intellisense will work properly.
I think this is a bug with Unity 2018.2 (at least, that is when my troubles started) … As you already pointed out, Unity no longer creates the .sln file. In my project, the .sln file is there but is no longer updated.
At least for now, following your approach by going Assets → Open C# Project works. Thank you
This issue is that Unity Editor expects the file used to launch VSCode to have a specific name. It seems that unity will only trigger the .sln/.csproj generation routine if the filename matches a hard-coded value.
Specifically, creating a symlink named “code” that opens VSCode fixed this issue for me. The normal binary was named “visual-studio-code”, which Unity didn’t recognize as VSCode.
Unity devs may want to consider a more sophisticated method of determining whether the selected external editor is VSCode, VS, etc.
Thank you guys for the workaround, I was using VSCode Insiders which has a different executable name and wouldn’t make Unity generate project files. Please upvote that suggestion so that we can have a decent behaviour with any code editor!
Didn’t work for me maybe because I’m using Arch and getting VS code from the AUR and the executable is code-oss. In the end I fixed it by using the symbolic link method:
Open Visual Studio Community(if you don’t have, install it)
Go to your unity Project folder
There will be a file like – ‘YOUR_PROJECT_NAME.sln’
Double click that file and choose to open in Visual Studio Community
It will load your solution file
Then it will show you a window saying unity is target to .net vsxxx and this is not installed in your computer. With 2 options
a. Download that .net framework version
b. change target .net framework version
Download the missing .net framework version by clicking the option
Open Visual Studio Community(if you don’t have, install it)
Go to your unity Project folder
There will be a file like – ‘YOUR_PROJECT_NAME.sln’
Double click that file and choose to open in Visual Studio Community
It will load your solution file
Then it will show you a window saying unity is target to .net vsxxx and this is not installed in your computer. With 2 options
a. Download that .net framework version
b. change target .net framework version
Download the missing .net framework version by clicking the option
I create empty project in 2019.2.0b1.
I set to External Script Editor the symlink sudo ln -s /snap/bin/code-insiders /usr/bin/code
Unity field “Script Editor” changed from file name to “Visual Studio Code”
Unity field “Script Editor Args” changed to "$(ProjectPath)" -g "$(File)":$(Line):$(Column)
I click Open C# Project, and get errors like:
Usage: open [OPTIONS] -- command
(Filename: Library/PackageCache/com.unity.ide.vscode@1.0.4/Editor/VSCodeScriptEditor.cs Line: 147)
UPDATE.
Create symbolik link is worng, it must be an alias sudo snap alias code-insiders code
Not working with vscode from snap
Not working with vscode insiders from snap or apt
Unity expect only/usr/bin/code for creating sln and csproj
But problem with arguments still happens, Unity tryes launch openvt not vscode.
Full log https://pastebin.com/uhrxQahv
Thanks Mate!
Started with unity 2 weeks ago. On windows it’s working fine, but on linux I have very big issues to make it run and there is very few information, because everything that you find online is already outdated and doesn’t work.
I have the same issues. No version of VSC works for me. C# Extension/omnisharp is not recognizing my files as .cs and when I installed another extension to create a cs file, it gave me an error that .json files could not be found. So I’m currently downloading the previos version. Hopefully I can make it work there.