VSCode for Linux not opening projects correctly

Good night!

I’ve trying to use VSCode as editor on my Unity (Ubuntu 18.04 LTS), but when I try to open files directly from Unity, the VSCode can’t find references (so my own classes and UnityEngine’s built-in variables and functions - such as gameObject, GetComponent etc. - are not available).

First, I thought it was a bug on integration betwen Unity for Linux and VSCode for Linux, but if I try to open (manually) my project’s folder into VSCode (root of project folder, not “Assets” or any sub-folders), all references are working normally!

So, I think Unity is not calling VSCode to open the full project path (like in Windows - I not test this on Mac because I don’t have a Mac), and, if I rename (or copy) the VSCode binary with another name (“/usr/bin/vscode” for example) and set Unity to use this “new” binary with “$(ProjectPath)” argument and try to open a script directly from Unity, all references works fine, but the specified file not opens automatically on VSCode (and all .meta files are visible if I not opened VSCode normally - the original “/usr/bin/code” binary - from Unity, for creating custom .vscode/settings.json file).

Is someone having this problem too? Can anyone help me with this :slight_smile: ?

Thank you so much for attention!

Sorry for my english rsrs I’m from Brazil :smile:

UPDATE:

Partially fixed. I’m using the “trick” (renaming the VSCode binary file to make custom arguments/parameters field available) and set the argument like this:

"$(ProjectPath)" "$(File)"

And all works fine. But, the only final problem is Unity not creating the custom “.vscode/settings.json” file, to suppress all .meta files and other unecessary files from VSCode’s workspace.

If someone has having this issue too,

2 Likes

2 Likes

I am experience the same problem. It used to work and after some time it is not working anymore.
I just updated to latest Linux version: Unity-2017.4.0f1 and it didn’t solve.
I cannot change my “External Script Editor Args” as RBFraphael because on my machine it display VScode as “code” and does not allow me to change any parameters…

My workarround:

  1. create VScode.sh
    #!/bin/sh
    /usr/share/code/code 1 *

  2. Change Unity->Edit->Preferences->ExternalTools browse your VScode.sh
    Script args: “(ProjectPath)" "-g (File):$(Line)”

2 Likes

Thanks for those tips !

How do you get Unity to build the csproj and sln ?

Hey guys!

Now I use a new method (more simple, I think) to let Unity use Visual Studio Code correctly on Linux :smile:

Here is my step-by-step:

  1. Create a symlink for /usr/bin/code with another name
    1.1. Open terminal and type sudo ln -s /usr/bin/code /usr/bin/vscode

  2. Set up Unity to use the Visual Studio Code with created symlink and correct args
    2.1. Go to Edit > Preferences and select External Tools tab
    2.2. Select the /usr/bin/vscode binary file on External Script Editor field
    2.3. Type "$(ProjectPath)" -g "$(File)":$(Line) on External Script Editor Args field

  3. Hide Unity’s .meta files in Visual Studio Code
    3.1. Open Visual Studio Code (with a new script, or shortcut, or whatever you want… just open it)
    3.2. Go to File > Preferences > Settings
    3.3. In the right panel, add the following code between the two keys ( { } )

"files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/*.meta": true
}

3.4. Save your settings ( Ctrl + S or File > Save)

  1. Be happy and create beautiful scripts :smile:

If my words are helpful for you, please give-me a thank you… This will not kill you :stuck_out_tongue: #Love

5 Likes

1 Like

Thank you sir, worked a charm! Even better than the VSCode asset from the store.

Unfortunately it doesn’t seem to be working for me. I’ve followed steps 1 and 2, but I still can’t get autocompletion to work with the projects.

Now I’ve realized that I don’t get that thing with the flame in the bottom bar, which seems to be relevant since it’s related to the C# plugin. Maybe it’s not recognizing the folder as a C# project for some reason? I can’t find any file called “New Unity Project.sln”.

Yea I had the same issue. The omnisharp server wasn’t connecting for some reason. I couldn’t figure it out sorry :confused: But I think its due to the C# extension more than anything. I just ended using monodevelop

I have similar problem, but nothing works for me. My Unity Hub doesn’t look like it try to run any program at all, because my script does not log anything and it is set to log.

I haven’t used Unity on Linux in a little while but last time I did vscode worked right out of the box, didn’t need to do anything. Make sure you have [.net](http:// https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/intro) and mono installed as well.

Also, if you’re not using Ubuntu 18.04 I know it doesn’t work 100%. I use Pop_os 18.04 and only issues are Unity doesn’t run as near as well as compared to Windows :rage:

I was using ubuntu 16.04 or 18.04 I’m not sure; but I had .net and mono installed. For now I just installed Windows on some spare HDD to use Unity. If I find solution it will be on linked forum thread.

I got better results with codium. Maybe this helps someone. I get things like transform or transform.Translate suggested. But no documentation.