简体   繁体   中英

Visual studio code Intellisense not working with Unity Engine?

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.

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.

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 .

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.

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

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

[SOLVED] After trying all the above answers it still didn't work. Actually sounds dumb but I never opened the solution explorer argh. 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. In my case after letting VS install it I had to right click on any other project in Solution Explorer and click reload project. Sweet Intellsense now works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM