VS Code doesn't recognise "using UnityEngine" as a valid namespace. What can I do?

Viewed 205

I opened the ".cs" file from Unity after creating a C# file in my project, however neither UnityEngine nor (obviously) MonoBehaviour is detected in VS Code.
Due to this, Intellisense also can't help, which is a major obsticle for me, because I am completely new to the UnityEngine library. The OmniSharp log also gives a warning in the output:

[fail]: OmniSharp.MSBuild.ProjectManager
        Attempted to update project that is not loaded: c:\Users\bomka\My project\Assembly-CSharp.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
        Inlay hints requested for document not in workspace Location { FileName = c:\Users\bomka\My project\Assets\scripts\Circle.cs, Range = Range { Start = Point { Line = 0, Column = 0 }, End = Point { Line = 19, Column = 0 } } }

Things I've tried so far:

  • I've redownloaded both Unity and VS Code (latest versions, which are 2021.3.3f1 and 1.67.2, respectively)
  • I checked whether Visual Studio Code Editor and Visual Studio Editor were downloaded in Unity's Package Library (they are, it's 1.2.5 and and 2.0.15, respectively)
  • I changed omnisharp.path to "latest" in VS Code because I've read it resolved the "Attempted to update project..." issue. It didn't really do anything unfortunately

Does anyone have any ideas concerning what I should do here? Another useful piece of information is that this is my first ever Unity Project and so VS Code didn't just decide to malfunction after a while, this is how it's been behaving since I started writing my first piece of code for my project.

Cheers!

1 Answers

Is VS set in your external tools in Unity?

Edit > Pref > External Tools > External (Script) Editor : Visual Studio..

Not sure if it'll help but I know the above will fix Intellisense issues so it might be worth a shot.

Related