Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Bug VSCode for Linux not opening projects correctly

Discussion in 'Linux' started by RBFraphael, Apr 22, 2018.

  1. RBFraphael

    RBFraphael

    Joined:
    Apr 21, 2018
    Posts:
    14
    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 :) ?

    Thank you so much for attention!

    Sorry for my english rsrs I'm from Brazil :D
     
  2. RBFraphael

    RBFraphael

    Joined:
    Apr 21, 2018
    Posts:
    14
    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,
     
    djoledjole2 and RedHillbilly like this.
  3. RBFraphael

    RBFraphael

    Joined:
    Apr 21, 2018
    Posts:
    14
  4. KammutierSpule

    KammutierSpule

    Joined:
    May 23, 2017
    Posts:
    4
    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..
     
  5. KammutierSpule

    KammutierSpule

    Joined:
    May 23, 2017
    Posts:
    4
    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)"
     
    lassade and huno92 like this.
  6. Corentin

    Corentin

    Joined:
    Dec 1, 2013
    Posts:
    16
    Thanks for those tips !

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

    RBFraphael

    Joined:
    Apr 21, 2018
    Posts:
    14
    Hey guys!

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

    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 (
    { }
    )
    Code (JavaScript):
    1. "files.exclude": {
    2.         "**/.git": true,
    3.         "**/.svn": true,
    4.         "**/.hg": true,
    5.         "**/CVS": true,
    6.         "**/.DS_Store": true,
    7.         "**/*.meta": true
    8. }
    3.4. Save your settings ( Ctrl + S or File > Save)​

    4. Be happy and create beautiful scripts :D

    If my words are helpful for you, please give-me a thank you... This will not kill you :p #Love
     
    Last edited: May 7, 2018
    djoledjole2, LazyGod, lassade and 2 others like this.
  8. RBFraphael

    RBFraphael

    Joined:
    Apr 21, 2018
    Posts:
    14
  9. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Thank you sir, worked a charm! Even better than the VSCode asset from the store.
     
  10. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    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".
     
    Last edited: Jun 28, 2018
  11. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    Yea I had the same issue. The omnisharp server wasn't connecting for some reason. I couldn't figure it out sorry :/ But I think its due to the C# extension more than anything. I just ended using monodevelop
     
  12. rafallauterbach

    rafallauterbach

    Joined:
    Jun 4, 2019
    Posts:
    5
  13. Brogan89

    Brogan89

    Joined:
    Jul 10, 2014
    Posts:
    244
    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 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 :mad:
     
  14. rafallauterbach

    rafallauterbach

    Joined:
    Jun 4, 2019
    Posts:
    5
    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.
     
  15. hongmap

    hongmap

    Joined:
    Jun 7, 2021
    Posts:
    1
    I got better results with codium. Maybe this helps someone. I get things like transform or transform.Translate suggested. But no documentation.