Intellisense Featured Image

Getting Visual Studio’s IntelliSense (auto-complete) to work for Unity

One of the most powerful features of Microsoft’s Visual Studio IDE is IntelliSense, which is basically a helper that shows you autocomplete suggestions as you write your code. It’s a tremendously helpful feature, especially if you’re using it to write code for Unity scripts.

Unity's IntelliSense
It’s the smartest thing in the world.

There are many different reasons why IntelliSense doesn’t work properly on a device, and with the Internet being the Internet, its answers are scattered all over the place. Hence, we’ve put together this article to collate the answers that we’ve found.

For ease of access, the sections of the article are outlined below:

  1. Is my IntelliSense working?
  2. Getting IntelliSense working
    1. Open your scripts from Unity
    2. Setting Unity’s External Script Editor
    3. Visual Studio Tools for Unity
    4. Check your .NET API compatibility level
  3. Conclusion

Article continues after the advertisement:


Is my IntelliSense working?

For IntelliSense to work with Unity’s libraries, Visual Studio needs to be linked to the Unity Editor and have the appropriate extensions installed. If you’ve installed Visual Studio via Unity Hub, this should all have been automatically set up.

Alas, accidents happen sometimes (in some versions of Unity 2019 and 2020, Visual Studio does not seem to integrate with Unity by default), and you might end up with an IntelliSense that is not properly set up.

Is IntelliSense set up?
If you see these things, then IntelliSense hasn’t been set up on your device.

To check if IntelliSense is properly set up, open any script from the Unity Editor, and look out for 2 things:

  1. Whether the top-left dropdown says Miscellaneous Files. If it does, then IntelliSense is not set up.
  2. Try declaring a Unity variable, like a GameObject. If IntelliSense is properly set up, Visual Studio should have an auto-complete suggestion for you before you finish typing.

Getting IntelliSense working

So if IntelliSense isn’t working for you, what should you do?

1. Open your scripts from Unity

Before you try anything else here, make sure that your scripts are opened from Unity, i.e. double-clicking on your script files in the Unity Editor to open and access Visual Studio.

If IntelliSense doesn’t work when you do this, then you’ll have to continue onto the steps below:

2. Setting Unity’s External Script Editor

From the Unity Editor, access the Preferences window from Edit > Preferences. Then, click on the External Tools tab.

Setting the External Script Editor
You’ll need to set the External Script Editor.

Set the External Script Editor to the version of Visual Studio that you installed alongside Unity. Then, restart Visual Studio and see if IntelliSense is now working. If it still doesn’t, then you might be missing…


Article continues after the advertisement:


3. Visual Studio Tools for Unity

To install this, open Visual Studio and go to Tools > Get Tools and Features.

Accessing the Visual Studio Installer
This opens the Visual Studio Installer.

Note: You’ll need administrator permissions to open this window, as it makes changes to an existing installation on your computer.

Once the installer is open, go to Workloads and find Game development with Unity. Check the box, and then click on the Modify button on the bottom-right corner to begin installation.

Finding the Game development with Unity workload
Install the Game development with Unity workload.

A popup may ask you to close certain processes before beginning installation. If this happens, close your Visual Studio project and the Unity Editor application.

When installation completes, restart both Unity and Visual Studio, then check to see if IntelliSense now works.

The Games development with Unity workload actually installs 2 additional Visual Studio components — Visual Studio Tools for Unity and C# and Visual Basic. You can install both modules individually by going to the Individual components tab, and checking both components in the list that is shown.

Finding Visual Studio Tools for Unity

Article continues after the advertisement:


4. Check your .NET API compatibility level

If IntelliSense still refuses to work, you can open the Unity Editor and head to Edit > Project Settings and access the Player (or Player Settings) tab. Scroll down to the Other Settings sub-tab, and find the Api Compatibility Level dropdown under the Configuration heading.

You want to set the Api Compatibility Level to a different option, and see which is the one that works for your device.

Setting the Api Compatibility Level
The Api Compatibility Level setting is nested quite deep in.

Conclusion

As with the other articles on the blog, we’d love if you leave a comment below, especially if you:

  1. Find any errors in this article, or;
  2. Find an IntelliSense fix that is not listed in this article

Your comments will add on to the information that is already here, and help other future readers!


Article continues after the advertisement:


Leave a Reply

Your email address will not be published.