1
\$\begingroup\$

I followed the official step-by-step "Visual Studio Code and Unity" guide, but it seems I messed up something, because Intellisense doesn't see any Unity related stuff.

Like the MonoBehaviour class and its members (like .transform), or the Unity callbacks, like Start or Update.

\$\endgroup\$
10
  • 2
    \$\begingroup\$ try to set right IDE in preferences-> external tools. if not it means you IDE and unity are not synched. most of the time it happens, i just uninstall both and reinstall them. new version of unity install Visual studio 2019 community with it. try to do that. \$\endgroup\$ – virtouso Sep 3 '19 at 11:32
  • 1
    \$\begingroup\$ This is a common issue on which you can find existing Q&A, including this one and many more you can find with a search. Typical solutions are to close Unity and your IDE, then delete the solution files in your project folder, letting Unity re-generate them the next time you load it and open a script. \$\endgroup\$ – DMGregory Sep 3 '19 at 11:34
  • \$\begingroup\$ @virtouso I just reinstalled my PC, and I didn't install VS19 Community with Unity because I wanted to use Code this time. Code uses the Unity Tools installed with VS19? \$\endgroup\$ – Tudvari Sep 3 '19 at 11:36
  • \$\begingroup\$ @Tudvari yes it does \$\endgroup\$ – virtouso Sep 3 '19 at 11:42
  • \$\begingroup\$ @virtouso Thanks a lot! :) \$\endgroup\$ – Tudvari Sep 3 '19 at 11:57
2
\$\begingroup\$

On a newly created project, opening a C# script via double clicking it won't correctly load VSCode's extensions. (this is due to parts of the sln file not being generated.)

Create at least one C# script, then go to 'Assets' > 'Open C# Project' will generate the correct sln file and after a quick reload of VSCode, intellisense starts working.

After doing this one time, intellisense will continue to work as expected, double clicking C# scripts etc.

\$\endgroup\$
1
  • \$\begingroup\$ After looking through many solutions to this problem yours was the one that helped me. \$\endgroup\$ – mirzak Aug 10 '20 at 20:19
1
\$\begingroup\$

Well, the source of this issue changes from issue to issue. So if this doesn't solve your issue, be sure to read further down below.

In my case it was due to changing the default install path for new applications.

I changed the default install path to my HDD, so I don't have to manually change every new application's install path from my SSD to my HDD.

The problem is that some applications only looks at the drive on which Windows is installed.

So now I change my default install path to my SSD every time I update Unity, so Visual Studio will be installed at the path where VS Code will look for the dlls.

But sometimes this won't be enough, for example this time I wasted some time again, and still haven't figured out the correct way of doing this. Maybe I will just give in, and always manually change the install path. What I did:

  • I had to uninstall Unity, Visual Studio, restart my computer
  • Then install Unity, Visual Studio, restart my computer,
  • In Unity > Preferences, switched the IDE to Visual Studio.
  • Opened the a file, which opened Visual Studio.
  • Switched the IDE to Visual Studio Code.
  • Works.

Update:

  • I've just uninstalled my old Unity, and installed the new one, and as it turns out, a Visual Studio reinstallation, and restarts aren't needed.

  • Just open a file with Visual Studio as an IDE, and then switch to Visual Studio Code.

\$\endgroup\$
0
\$\begingroup\$

I had the same problem when I started using unity and visual studio. Here's how I got around it: to open a c# file from unity, what most people do is double click on the script. the problem with this for me, was that it only opened the file, not the c# project. So, make sure you've opened the c# file by double clicking before, and then, in visual studios, click File-Open Project/Solution and then navigate to the folder you've saved your unity project in. In that folder, there should be a C# project file.(if there isn't, just double click on the script in unity, close the script, and try to open the project file again.) open it, and voila! If your having the same problem i was, intellisense should be working with unity!

I hope this was helpful.

\$\endgroup\$
2
  • \$\begingroup\$ Didn't fix it :\ On my other PC one of the suggestions in the above comments fixed it, but on this PC, it doesn't. It says: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1175,5): Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found \$\endgroup\$ – Tudvari Sep 3 '19 at 20:07
  • \$\begingroup\$ I hope you can find an answer, I don't think I can help you :( \$\endgroup\$ – Millard Sep 3 '19 at 20:10
0
\$\begingroup\$

It's not a new issue. I just faced such a problem and mostly that's because Unity and VS or other IDEs are not synced. Sometimes even going to Preferences and setting the chosen IDE even doesn't work. C# classes are known as miscellaneous and auto-complete can't find the right choices.

Sometimes it's because you use a cracked version of VS or Unity or just downloaded them from an unofficial source.

Most of the time I choose the last solution first. Just remove both VS and Unity and download them from their official website. From the time I used official versions I just don't face such problems.

\$\endgroup\$
0
\$\begingroup\$
  1. Open VSCode

  2. Uninstall all C# extensions you have installed (Only to avoid conflicts with new extensions)

  3. File -> Open Folder -> (Select your unity project folder)

  4. VSCode will automatically install the required extensions.

  5. Start typing in your code.

  6. I'm attaching the snapshot of my VSCode working with my unity mini-project.

IntelliSense

Hope this helps you.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.