3

I'm not sure what happened but the option to 'go to definition' suddenly dissapeared in VSCode for Unity projects.

I've tried reinstalling VSCode and Omnisharp, the Unity plugins, tried a new Unity project and an Asp.net C# project and still no luck.

Any ideas how I can diagnose to fix this?

meds
  • 21,699
  • 37
  • 163
  • 314

5 Answers5

3

I had the same problem and was able to fix it.

  • Visual Studio Code Version: 1.63.2
  • Unity Version: 2020.3.25f1

-> After installing, follow the instructions on https://code.visualstudio.com/docs/other/unity

  • In Unity, go to Edit > Preferences, as shown below.

Edit > Preferences

  • After that you have to set "Visual Studio Code" as "External Script Editor" under "External Tools" as shown below.
  • After that check everything under "Generate .csproj files for:".

Settings

-> After pressing "Regenerate project files" everything worked for me.

enter image description here

  • Keyboard shortcut is CTRL + Click or F12.
3

For me, I tried everything, but it was the answer by "chantey" in this post which helped me in the end. I found that I could:

  1. Open the "OUTPUT" tab in the bottom area where the DEBUG CONSOLE etc is in VSCode.
  2. Select "OmniSharp Log" in the dropdown for which output to see.
  3. Try using Go to definition (F12) in the editor. It showed the error "OniSharp Error: Found dotnet version 3.(...). Minimum required version is 6.0.100"
  4. This lead me to the post I mentioned "OniSharp Error: Found dotnet version 5.0.201. Minimum required version is 6.0.100". I followed the instructions from chantey.
  5. Then I closed VSCode and chose "Assets/Open C# Project" again in Unity.
  6. Once VSCode started, I had to wait for a minute or so while OmniSharp was re-downloaded. This happened automatically. I closed Vand I could follow this process in the Output tab for C#.

Finally it worked!!! :D

EDIT: I also found this post where they solved it by updating the .NET SDK. I haven't tried it, but perhaps that's an even better solution if it works.

  • If you are here in 2022 and this only just started happening to you, THIS IS YOUR ANSWER! – puzzl Jun 14 '22 at 14:53
0

It is a while back, but for others who come across this: Check if you have the folder opened in Visual Studio which contains the .csproj files. These hold those references. If you opened one folder deeper, it cannot find those references and will give those problems.

Amber Elferink
  • 132
  • 1
  • 10
-1

Try clicking F12 - it's a shortcut.

Sora
  • 50
  • 4
-1

If your vscode has installed Unity Tools for Visual Studio Code (Tobiah.unity-tools), uninstall it and retry.

feisan
  • 192
  • 6