Search Unity

Visual Studio Code Intellisense Not Working.

Discussion in 'Editor & General Support' started by alti, Jun 19, 2020.

  1. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    I had a very interesting case on my hands. While working on my project on my desktop, my graphics card or something crapped out, so I'm on my laptop now.

    I managed to get the project from off my internal HDD and onto my laptop.

    I opened the project in unity and worked for a few days on some level design, but eventually I wanted to do some things from code. From there I realized intellisense wasn't working.

    So I thought, "Ok, nbd, this has happened many many times before. Let's solve it."

    So I did the following:

    1. went to preferences > external tools: switched it to visual studio code...checked all the boxes and tested. unchecked all the boxes and tested. regenerated project files. Reset argument, etc.
    2. Downloaded all the frame works here: https://code.visualstudio.com/docs/other/unity
    3. restarted my computer.
    4. started visual studio before unity
    5. downloaded and SUCCESSFULLY got intellisense to work in Visual Studio Community 2019 (and its unity extension), but still when opening visual studio code it didn't work
    6. deleted the .vs and .vscode folders from the projects root folder
    7. deleted the project settings in the root > project settings folder.
    8. Downloaded from the extensions marketplace the C# for vs code pack from microsoft. And unity tools. And unity code nuggets. And unity debugger.
    9. and a lot more. If you comment I'll respond with whether or not I tried it.

    I'm exhausted. I've been at this since 10am this morning, and it's 7:30pm now. I seriously don't know what more I could do to get intellisense to work. And I sometimes get an error that says "Some projects have trouble loading. Please review the output for more details." And that says:
    OmniSharp.MSBuild.ProjectManager
    Attempted to update project that is not loaded: c:\xxx\Unity.ShaderGraph.Utilities.csproj, among other paths.

    so I....."10." added the word "latest" to the omnipath.json file in settings. Seriously I feel like I have tried everything and I'm very frustrated. After all this I can't get intellisense to work in visual studio code, but somehow it works in visual studio community 2019? Makes no sense. Somebody help :C

    I'm willing to jump ship and either use visual studio community 2019, but I like how lightweight code is. If anybody has suggestions for other text editors, I'm willing to check them out.

    oh, and 11. I uninstalled and reinstalled the visual studio package from the package manager. It literally does nothing.

    edit: 12. I updated unity as well. (turning meshes on and off is super slow in the latest release, has anybody noticed? Can that be fixed?) 2019.4.something.

    13. I checked to see if intellisense was working by typing things like "rigidbody" and "gameobject" and if the words weren't already in the file, they wouldn't appear.

    NOTE: I think I might be missing a .sln file. Where would I find that and how can I get visual studio code to recognize it?
     
    Last edited: Jun 19, 2020
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,914
  3. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
  4. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,914
    Ah sorry about that. I'll admit I only skimmed your post and I saw #5 but then interpreted the rest of your post as "and then it stopped working again". I'll show myself out.
     
  5. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    no worries. this is weird. I've delt with this problem before, but this is a particularly specific problem. I don't know, might have something to do with moving projects between computers? I am clueless.
     
  6. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    FIXED!!!!! I really only posted here for good luck lmao. It always happens that I have a crushing problem and try to research it myself, and fail until I post. Then I continue to research and discover the answer.

    https://forum.unity.com/threads/sol...g-sln-file-from-assets-open-c-project.538487/

    Apparently after going through the attempt in #1, Unity (in some cases because who knows) requires you to go to "assets > Open C# Project", which I guess recreates a .sln file, in case it gets corrupt or is lost, or something.

    The steps I took are as follows:

    1. opened visual studio code and downloaded "vscode-solution-explorer"
    2. got the error that read a .sln couldn't be found.
    3. went to unity > assets > open C# project
    5. opened a c# file from the unity project folder explorer.
    4. intellisense was still not working (but it opened in a brand new vs window).
    6. went to the extension manager and disabled, then enabled the C# for visual studio extension.

    voila! It works!

    I have no idea really why that worked, but I assume it has something to do with generating a .sln.

    posting the process in case someone else has a problem in the future. This was a doozey, and I'd hate for someone else to waste a day of work over the same discrepancy.


    Edit: it's worth noting, that having to get intellisense to work this way requires that you open the scripts from assets > open C# project. And then disable and enable the MS "C#
    for visual studio" extension. It's a weird prerequisite, which I didn't have to do before, but it's better than nothing. Will update if i discover anything else.
     
    Last edited: Jun 19, 2020
    LyneChu, Ziberian, batuhangc and 2 others like this.
  7. game_factory_

    game_factory_

    Joined:
    Sep 23, 2016
    Posts:
    2
    Same problem, I got after reinstalling windows and copying project files, still can't fix. I am using Vscode without intelligence since 1 month. Do you prefer any other applications?
     
  8. deltameta

    deltameta

    Joined:
    Nov 30, 2020
    Posts:
    5
    I bit the bullet and downloaded the full Visual Studio for Mac. I gave up on Visual Studio Code after a few hours of going in frustrating circles and trying several suggestions on the Unity forum and StackOverflow that didn't work.

    One thing I noticed right off the bat is that the Visual Studio installation will automatically prompt you to download the necessary .NET stuff. I didn't have to run any commands to install things once Visual Studio was installed (although, I did download the dotnet and Mono installations previously for VS Code, so who knows if these were used or not...).

    Once Visual Studio for Mac is installed, I went into Unity and gave Visual Studio Code the ol' boot by updating my preferences to open Visual Studio as my external editor:
    Unity version: 2020.3
    Unity > Preferences > External Tools > External Script Editor > Visual Studio for Mac [8.10.11]
    I've also got Package Manager > Visual Studio Editor installed (2.0.11)

    Finally, I opened my .cs file from within Unity (alternatively, you can right-click and select Open C# Project). Once Visual Studio opened:
    Visual Studio > Preferences > Theme > Dark (we aren't barbarians...)
    ...and then File > Open > and opened my Unity game .sln file.
    I went to the script in question to try things out and badda-bing-badda-boom, intellisense and all my stuff worked and opened without a hitch.

    Best of luck.
     
  9. for3st

    for3st

    Joined:
    Mar 21, 2020
    Posts:
    2
  10. kael81

    kael81

    Joined:
    Mar 19, 2022
    Posts:
    2
    Edit > Project Settings > Player > Configuration > Api Compatibility Level
    change from .NET 2.x to 4.x
    Edit > Preferences > External Tools
    click Regenerate project files (all options unchecked)
     
    ryan-at-melcher and chris60000 like this.
  11. victorliu233

    victorliu233

    Joined:
    Aug 28, 2022
    Posts:
    5
    I have the similar issue. When I opened one project, the extension worked well. When I opened another project, the project wouldn't work but the first one still worked...Then I closed all projects and opened the one that was not working, this time it worked. I guess something was wrong about the solution setting? So it is confused by multiple projects.