Maximus
Maximus

Reputation: 31

VSCode Unity Cant get working suggestion (even Debug.Log isnt autocompleting)

So I tried to uninstall VSCode, deleting all its files and folders and following guides to reset it. I have dotnet sdk installed, and in VSC terminal dotnet command works I have C# Extension in VSCode installed. In Unity I select VSCode as default script editor, and regenerate all .csproj files. They show up in VSCode when I open a script.

I create new script, open it, and start typing "De" to see if "Debug.Log" gets suggested. Its like VSCode never heard of it DebugL gets offered to autocomplete with lock What am I doing wrong? Windows 10

Upvotes: 1

Views: 1159

Answers (6)

Saleh Hosseini
Saleh Hosseini

Reputation: 523

  • Make sure the C# extention in VSCode is uninstalled
  • Kill any VSCode process using the Task Manager (ctrl+shift+esc in Windows)
  • Install the dotnet SDK from https://dotnet.microsoft.com/download
  • Locate your dotnet using where.exe dotnet command in a cmd
  • Add the address that you get to the system path. follow this link
  • Reboot your device
  • In VSCode, install C# extention
  • In Unity -> edit -> preferences -> external tools, set External Script Editor to Visual Studio Code
  • Hit Regenerate Project Files button
  • Now open a script file from inside Unity and see if it's fixed

Upvotes: 0

user16223274
user16223274

Reputation:

Go to Project settings/external tools and set the visualstudiocode.exe as the script editor

Upvotes: 0

Shih-Chieh Chou
Shih-Chieh Chou

Reputation: 1

I just faced this problem, and fix it by following this link.

Here is my steps:

  1. In Unity Editor, go to Window/Package Manager.
  2. Click "Packages: In Project" combobox, and select "Unity Registry".
  3. Search Visual Studio Code Editor and install.
  4. Then go to Edit/Preferences, find External Tools on the left.
  5. Change External Script Editor to where your vscode installed.
  6. Click ""Regenerate project files".
  7. In VSCode, Install C# Extension.

(Close vscode) Now open a c# file from Unity, and see bottom of your vscode. (the OmniSharp fire and Analyzing)

If it works you will see this. And your intellisense should work now.

If not there maybe:

  1. You cannot find the fire icon. -> It means your OmniSharp server is not running.
  2. Error running the project. -> Click on OnmiSharp fire icon, and it will show errors.

PS. I'm using Unity 2021.3.5f1

PS2. Stackoverfolow not allow me to post a image.

Upvotes: 0

Zeyad Shaban
Zeyad Shaban

Reputation: 1016

I had this issue, you can't open C# files by double clicking in Unity, this will work in visuals studio but not visual studio code

Instead right click on an empty space on your project tab and you should find an option for "Open C# project" press on that (you need to make sure that vs code is your default external code editing tool) and you are good to go

Additionally, you need to make sure you have the C# extension and you installed all required C# stuff like .NET framework, mono, or whatever

little tip: install unity tools and unity snippets extensions for better experience

if it didn't work what is your OS?

Upvotes: 0

pranay gv
pranay gv

Reputation: 1

Try following the steps in this link
https://code.visualstudio.com/docs/editor/intellisense

Upvotes: 0

JackQx
JackQx

Reputation: 172

I had the same problem for along time but I think it is because Unity are using UnityScript So it is very similar to c# But in Unity There is some little different I think this is why it is not working .

SOLUTION 1:

try downloading Unity snippets extension Just Go To

File>Preferences>extensions

type Unity And Download these 3 extensions I find it more better than the original c# extension

Unity extensions

Here is The Links

Unity Snippets

Unity Code Snippets

Unity Tools

SOLUTION 2:

If none of the above Worked then the best solution is to download the Visual Studio IDE from Microsoft

Delete VS Code you have and download the Microsoft version [Link above] And Then you can Choose to download the Unity package from the start menu. so no need to download any extensions ..... This Is The Best Solution for your problem there is no fix Just Download And That's it

Upvotes: 2

Related Questions