How to get intellisense in Visual Studio Code for Unity functions names?

58,728

Solution 1

Old question, but I had the same problem just recently.

There must have been an issue in your Assembly-CSharp.csproj or project-name.sln files. Most likely to be the .csproj file. If you take a look at it, you will see various references to .dll files.

You can tell Unity (my version: v2019.2.20f1) to create these for you by enabling Edit > Preferences > Generate all .csproj files.

 1. Delete both files.
 2. Enable .csproj file generation.
 3. Double click on a script in Unity.

This fixed my issue.

Solution 2

Although the answer by Alex Myers is helps, its not 100% right. Unity Snippets does give you some snippets, and the illusion of typeahead, it's not actually intellisense.

For true intellisense you need to:

More information can be found here: https://code.visualstudio.com/docs/languages/dotnet

You can test you have dotnet installed by typing dotnet into the terminal within VSCode.

Note In the image below how I get a full method signature, reference counts, and the yellow hint globe. These are only available when using dotnet + extension (and not available when using the snippets)

enter image description here

Solution 3

I would really like to clear things up a bit for everyone trying to get intellisense working with Visual Studio Code.

First of all I am writing this for Unity 2019.4.14 as it is the newest version.

These are the things you MUST do for this to work:

  1. You need Visual Studio Code (duh)
  2. The .NET Framework Dev Pac (not just the .NET core, not even the .NET core SDK, but the Framework Dev Pack because otherwise VSCode is going to be throwing this error:

The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application.

  1. Check if you have .NET installed by typing dotnet in the VSCode terminal.
  2. In VSCode search for the 'C# for Visual Studio Code' extension and install it
  3. In Unity go to Package Manager and install Visual Studio Code Editor. This will enable Unity to generate proper project files for VSCode.
  4. In Unity go to Edit -> Preferences -> External Tools and choose VSCode from the dropdown (could be listed as code.cmd) and after you choose it tick all the checkboxes you want in the Generate .csproj files for section. I checked Embedded Packages, Local Packages, and Packages from unknown sources. Click 'Regenerate project files'
  5. Open any C# file from Unity and you should be good to go.

Now, what about Unity Code Snippets and Debugger for Unity extensions? Well these are useful helper extensions but they have nothing to do with Intellisense. The first is for quickly typping common Unity patterns and the second is for showing Unity Debug warnings and errors as you type instead of saving and going back to Unity and reading the console.

Hope this was of any help.

Solution 4

Check out the guide for Unity Development with VS Code. They recommend a few extensions:

I believe the Unity Snippets extension is what you are looking for.

Solution 5

Note: my solution does not solve intellisense to function names, but this was the first question that come in fixing intellisense more generally in VSCode.

I needed to update the VSCode package in unity.

In Unity, click Window, then Package Manager, then look for Visual Studio Code Editor. Expand it by pressing triangle, and upgrade to the latest version (for me, it was 1.2.0. I restarted VSCode and it worked.

v1.1.4 had a bug that caused this problem, and was not fixed for about 3 months. It is still the default package installed with a new default project, so you have to change this package version to 1.2.0 in every new project, until they update it.

Screenshot of package manager with V1.2.0

Share:
58,728
Yone
Author by

Yone

Updated on January 23, 2022

Comments

  • Yone
    Yone over 2 years

    I am following a tutorial about Unity and I see that the instructor has intellisense when writes the method's name.

    However I have only intellisense with classes and variables, I mean Unity classes like Rigidbody and my own variables.

    enter image description here

    I have also read: Autocompletion not working in Visual studio

    How to enable intellisense in Visual Studio 2017 for Unity

  • DCON
    DCON over 4 years
    Simply installing C# extension helped me, +1
  • Ashik
    Ashik about 4 years
    Hello there, I am having trouble understanding this solution. Delete both files means?
  • Mehmet Fırat Koloğlu
    Mehmet Fırat Koloğlu about 4 years
    Sorry for the obscurity. Assembly-CSharp.csproj and project-name.sln.
  • Chris Jang
    Chris Jang almost 4 years
    +1 This was the issue for me; I updated from 1.2.0 to 1.2.1 and that fixed the Intellisense issues for me.
  • Jon Plotner
    Jon Plotner almost 4 years
    This fixed it for me. Thank you. As of version 2019.4 the path to regenerate is Edit>Preferences>ExternalTools>Regenerate project files
  • redcurry
    redcurry over 3 years
    I solved it by choosing the External Script Editor to Visual Studio (in Edit > Preferences > External Tools). The choice was "Open by file extension," and that choice didn't create the .csproj files.
  • dvlcube
    dvlcube over 3 years
    Unity 2020.1.11f1 (with Visual Studio Code Editor 1.2.3) on Ubuntu 20.04. On vs code, I also needed to change C# extension settings: "Omnisharp: Use Global Mono" to "always", after installing latest mono on my system.
  • Terence
    Terence over 3 years
    Do we need .net framework for this? As far as I know, Unity is using Mono.
  • Baboo
    Baboo about 3 years
    Pay attention to the Dev Pack version if you dont want to waste some time like I did: 4.7.1
  • nwp
    nwp almost 3 years
    There doesn't seem to be any .Net Framework Dev Pack, .Net Developer Pack or anything similar in the VSC extensions. There is a .Net Core Extension Pack, but you said that's not it. There is a Unity Dev Pack. Is that what you meant?
  • xtreampb
    xtreampb over 2 years
    In newer unity editors (version 2020 at least) i had to change in the Edit->Preferences->External Tools->External Script Editor from Open By Script Extension to Visual Studio Code. This updated the preferences windows with more check boxes. I left them all unchecked (default). I then clicked Regenerate project files button,
  • Aleksandar Ruseski
    Aleksandar Ruseski over 2 years
    @nwp the dev pack is not a VSC extension, it's a library of itself. here microsoft.com/en-us/download/details.aspx?id=56119
  • Aleksandar Ruseski
    Aleksandar Ruseski over 2 years
    @Terence That's what it says in the guide for installing VSCode for Unity code.visualstudio.com/docs/other/unity
  • GoldenArcher
    GoldenArcher over 2 years
    For me, I installed C# extension, but the .net version was not correct (I had several older versions that's installed with Visual Studio). Also check the console to make sure all the versions are correctly installed.
  • asciidude
    asciidude over 2 years
    This was not the author's question.
  • Thibaut Schwarz
    Thibaut Schwarz about 2 years
    okay so what is wrong with my answer? When I had the same problem I had to take these steps to finally get the autocompletion working so it can't be so wrong :|
  • strider
    strider about 2 years
    just remember to install MonoDevelop some how
  • Aleksandar Ruseski
    Aleksandar Ruseski almost 2 years
    note to self: in case Intellisense is not working it might be a problem with OmniSharp server (dot net version or whatnot)