Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Can't get VSCode to work properly with Unity

Discussion in 'Linux Editor' started by Kurolox, Jun 28, 2018.

  1. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    I've been trying to get Intellisense to work, but I don't get any relevant autocompletion like other people I've seen here.

    I've followed the instructions on this post: https://forum.unity.com/threads/vscode-for-linux-not-opening-projects-correctly.527924/

    This is what I'm getting, compared to the screenshots in that thread. https://i.imgur.com/bDtoKzn.png

    Not sure what could be happening. The C# extension is installed, and mono too. I've followed the steps indicated here too: https://code.visualstudio.com/docs/other/unity but I can't get it to work properly.

    Here's how I have vscode set up from Unity: https://i.imgur.com/ROBbCEl.png

    I hope anyone here could have a lead regarding what I'm missing.
     
  2. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    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?
     
  3. DGLWilkins

    DGLWilkins

    Joined:
    Sep 25, 2012
    Posts:
    6
    Your dead on with the issue being Unity not creating the .sln files. I've been having the exact same issue as well since updating Unity.
     
    Last edited: Jun 30, 2018
  4. Kurolox

    Kurolox

    Joined:
    Aug 13, 2015
    Posts:
    4
    I've found a workaround to generate the .sln files.

    1. go to Edit -> Preferences, then select the External tools tab
    2. 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
    3. If you selected the correct executable, there shouldn't be any External Script Editor Args field.
    4. 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.
    5. 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.

    Let me know if it works for you too.
     
  5. DevinDazzlr

    DevinDazzlr

    Joined:
    Dec 3, 2013
    Posts:
    1
    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 :)
     
  6. unityoracle

    unityoracle

    Joined:
    Jul 3, 2018
    Posts:
    12
    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.
     
    Novack likes this.
  7. LitchiSzu

    LitchiSzu

    Joined:
    May 14, 2016
    Posts:
    17
  8. DGLWilkins

    DGLWilkins

    Joined:
    Sep 25, 2012
    Posts:
    6
    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:

    sudo ln -s /usr/bin/code-oss /usr/bin/code


    Then followed your steps and got it working.
     
  9. marchinram

    marchinram

    Joined:
    Jan 28, 2014
    Posts:
    4
    Make sure project name doesnt have a space in it, messes with vs code
     
    The7thNoodle likes this.