visual studio code unity intellisense sometimes not working code example

Example 1: intellisense not working visual studio unity

In Unity Editor Go to Menu,
Click on Edit -> Preferences -> External Tools -> External Script Editor.
Set it to Visual Studio (your installed version of VS). ...
Check if it works, if not close Visual Studio.
Now Open cs file from Unity Editor, and now it should work.

Example 2: unity visual studio code intellisense not working

In Unity editor:
1. Go to Edit/Preferences...
2. Click on External Tools
3. Under where it says "Generate .csproj files for:", check any one of
	the boxes (I personally clicked Embedded Packages but I don't believe
    it matters)
4. Click the "Regenerate project files" button
5. Close Visual Studio Code if it wasn't already closed
6. Reopen Visual Studio Code - intellisense should now (hopefully) be working