How to link Visual Studio Community with Unity

If you use Visual Studio Community as your code editor, it’s recommended to have it propperly linked to your Unity project in order to enable advanced IDE features like: IntelliSense, error detection, navigation, refactoring and debugging.

0.- How to know if Visual Studio is propperly linked? #

Open any unity script double clicking it form Unity.

If any of these problems appear, Visual Studio is not propperly linked:

  • When double clicking, Visual Studio does not open automatically
  • When opening a second script, another completely different window of Visual Studio opens instead of a new tab on the current window
  • After 30s or so, the “MonoBehaviour” word on the script is white
  • After 30s or so, on top of the script class name “Unity Script 1 XXX references” does not appear
  • After 30s or so, the Start o Update functions do not turn blue

If Visual Studio is not propperly linked, you can check multiple things to make sure it’s linked:

1.- Visual Studio Community is not propperly installed #

Make sure that you have Visual Studio Community correctly installed, you can check on how to do it right in this tutorial: Unity – Installation – IDE

1.1.- The Unity workload for Visual Studio is not installed #

If you have Visual Studio Community correctly installed, make sure that you have installed correctly the Unity workload and all the required individual components. You can check out a tutorial on how to do so in: Unity – Installation – Configuring Visual Studio

2.- Visual Studio Community package is not installed or up to date on the Unity project #

From Unity open the menu “Window > Package Manager”

  1. On the left menu, click “Unity Registry”
  2. On the search box enter “Visual Studio”
  3. Once the package list refreshes (This can last for more than a minute on the first time) select “Visual Studio Editor”
  4. Click on the “Install” or “Update” button on the right menu and wait for the installation to finish

3.- The external tools are not propperly configured in Unity #

From Unity open the menu “Edit > Preferences…”

  1. On the left menu, click “External Tools”
  2. On the External Script Editor dropdown select “Visual Studio 2022” or the newest version available
    • If you don’t see any Visual Studio Community options in here, check the previous steps and restart your computer
  3. Click on “Regenerate project files”
  4. Restart Unity and Visual Studio