Problem: IntelliSense is not working for Unity specific methods and functions (i.e., Update
, FixedUpdate
, Awake
, etc.).
It does work, however, for non Unity specific methods (i.e., IEnumerator
, void
, public
, float
, int
, etc.) and for Unity specific variables (i.e., Gameobject
, transform
, camera
, etc.) and Unity specific namespaces (i.e., UnityEngine
, UnityEditor
, Unity
, etc.).
I am using: Visual Studio Code 1.41, Unity 3d 2018.4.15f1 (I have the same problem when using 2019.2.x).
I have tried the following solutions to no results:
<TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>
to <TargetFrameworkVersion>(Currently installed version)</TargetFrameworkVersion>
but unity automatically defaults back to v4.7.1Possible problems:
The sln file the project creates reads
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{B2B58FB2-4462-6B0C-A872-40DD957E5FE0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B2B58FB2-4462-6B0C-A872-40DD957E5FE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B2B58FB2-4462-6B0C-A872-40DD957E5FE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B2B58FB2-4462-6B0C-A872-40DD957E5FE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B2B58FB2-4462-6B0C-A872-40DD957E5FE0}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Assembly-CSharp.csproj
EndGlobalSection
EndGlobal
For some reason, the sln file seems to be used for Visual Studio 2010. I do not know if this is intentional or if this is the problem.
When attempting solution 4, as stated above, Unity (or VS Code for all I know) automatically changes .NET version from whatever I manually typed to 4.7.1. I have 4.7.1 already installed so this may not be the problem.
Extra information:
Here is the omnisharp log:
Starting OmniSharp server at 2020. 1. 20. 오후 9:08:43
Target: c:\Users\stpau\New Unity Project\New Unity Project.sln
OmniSharp server started.
Path: C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\OmniSharp.exe
PID: 2232
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 16.3 - "C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.3 - "C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild\Current\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild\Current\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild
MSBuildToolsPath = C:\Users\stpau\.vscode\extensions\ms-vscode.csharp-1.21.9\.omnisharp\1.34.9\.msbuild\Current\Bin
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\stpau\New Unity Project'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'c:\Users\stpau\New Unity Project\New Unity Project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\stpau\New Unity Project\Assembly-CSharp.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\stpau\New Unity Project'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\stpau\New Unity Project\Assembly-CSharp.csproj
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\stpau\New Unity Project' on host 8980.
[info]: OmniSharp.MSBuild.ProjectManager
Successfully loaded project file 'c:\Users\stpau\New Unity Project\Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
Adding project 'c:\Users\stpau\New Unity Project\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Update project: Assembly-CSharp
How can I solve this problem? I also asked this question on both reddit and the Unity forums with no success.
In the latest version of VS Code and Omnisharp, I had the same problem and solved enabling this option in Unity:
Edit > Preferences > External Tools > Generate all .csproj files.
Had the same problem using VSCode 1.41.1 and Unity 2019.4.0f1.
I was able to fix it by following these steps:
https://dotnet.microsoft.com/download/dotnet-framework/thank-you/net471-developer-pack-offline-installer
in Unity, go to Edit > Project Settings > Player > API Compatibility Level and change it to .NET 4.x
restart VSCode & Unity
IntelliSense works fine now and I don't get any errors when loading .cs files in VSCode anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With