4

I am currently working on a C# file and my Intellisense doesn't seem to be working on Visual Studio Code. I have tried generating all .csproj files as well as downloading the .Net framework dev pack 4.2 and changed the Api Compatibility Level to .NET 4.x accordingly. An example of intellisense that would be helpful is something simple like

Vector2 touchPosition = Camera.main.ScreenTowWorldPoint(touch.position);

when I type Camera.main. and attempt to use the intellisense I would expect to see the function ScreenToWorldPoint(Vector2) as a possible function I could use but nothing shows.

zCUa
  • 99
  • 1
  • 1
  • 5
  • 2
    Does this answer your question? [How to get intellisense in Visual Studio Code for Unity functions names?](https://stackoverflow.com/questions/52189426/how-to-get-intellisense-in-visual-studio-code-for-unity-functions-names) – Ruzihm Dec 20 '21 at 19:49
  • No, I saw this post but I used each of the suggested solutions and none seem to be working. As I mentioned in the question I tried some of the top voted solutions and still not working for me. The question is the same though so I suppose I could post on there but I am unable to due to having a new account. – zCUa Dec 20 '21 at 21:44
  • I notice this one isn't there "VS Code > C# Extension (installed) > Extension setting > search for : mono > set the option to Always". There's something there for "if you're on mac" but this helps some on windows too – Ruzihm Dec 20 '21 at 22:34
  • I changed the setting in the Settings.json ```omnisharp.useGlobalMono": "always"```. After doing that I restarted Omnisharp and VSCode, but same issues persists. I also tried adding the following extensions: ```Debugger for Unity, Unity Snippets, Unity Tools``` – zCUa Dec 20 '21 at 23:50

6 Answers6

5

Finally solved the issue.

First had to make sure that it wasn't a duel drive problem with Unity on D: drive and VS Code on C:

and then after reinstalling that when you open a C# file the IntelliSense may still not work.

To fix that I had to select Assets > Open C# Project After you do that if you open a C# script even just by double clicking the IntelliSense works fine.

Peter Csala
  • 17,736
  • 16
  • 35
  • 75
zCUa
  • 99
  • 1
  • 1
  • 5
3

You don't have to uninstall anything just follow these steps and everything will be fine:

  1. Close the Visual Studio.
  2. Open the unity Preferences from the toolbar and select the external tools.
  3. Then, External Script Editor chose (Open the file by extension) and instantly changed it to visual studio.
  4. Open your code file IntelliSense will work.

enter image description here

0
Preferences > External Tools > External Script Editor

Set this to VSCode, or whichever editor you want. Make sure you have the VSCode editor package installed, found here.

bnzzy
  • 1
  • 3
  • I tried the following but still doesn't seem to be working. I have tried multiple other solutions but it seems nothing is working. My intellisense works perfectly fine when using JS or other languages but it seems C# in general doesn't appear to be working. – zCUa Dec 22 '21 at 10:14
0

None of the solutions worked for me so what I did is Uninstalled all the .NET Softwares that were installed on my Machine. ---> I uninstalled these

Then I reinstalled the software from here
----> Install this version of .Net from here ⬇

https://dotnet.microsoft.com/en-us/download

Install this version of targeting pack from here ⬇

https://dotnet.microsoft.com/en-us/download/dotnet-framework/net471

After all this, I just reloaded the Vs code Window and it worked for me.

  • 1
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/31905132) – MD. RAKIB HASAN Jun 03 '22 at 05:31
0

On Ubuntu, putting this is your settings.json file should fix it: "omnisharp.useModernNet": false

AriyanDC
  • 3
  • 2
-2

[SOLVED] After trying all the above answers it still didn't work. Actually sounds dumb but I never opened the solution explorer argh!

Solution: When I did I found it was not compatible because I never installed the unity add on in visual studio. After clicking the project in VS it offered to install the add on for me. After letting VS install it, I did right click on other project in Solution Explorer and click reload project. 'Intellisense' works now.

MarmiK
  • 5,639
  • 6
  • 40
  • 49