[英]Unity intellisense in VScode not working and Omnisharp is giving multiple errors and warnings
所以,我對編碼有點陌生。 我正在 Unity 中制作游戲,我剛開始編寫腳本。 不幸的是,VScode 不適合我。 我已經在 VScode 中安裝了最新的 C# 擴展,.NET 版本是 6.0.401。
每當我啟動 IDE 時,我都會收到一條錯誤消息
Some projects have trouble loading. Please review the output for more details.
Source: C# (Extension)
當我檢查 output 時,它是這樣說的:
Target: c:\Users\Drews\My project
OmniSharp server started with .NET 6.0.401
.
Path: c:\Users\Drews\.vscode\extensions\ms-dotnettools.csharp-1.25.0-win32-
x64\.omnisharp\1.39.0-net6.0\OmniSharp.dll
PID: 6088
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 10.0.22000.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: .NET Core SDK 6.0.401 17.3.1 - "C:\Program Files\dotnet\sdk\6.0.401\"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: .NET Core SDK 6.0.401 17.3.1 - "C:\Program
Files\dotnet\sdk\6.0.401\"
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider:
OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.MSBuild.ProjectSystem
Detecting projects in 'c:\Users\Drews\My project\My project.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\Drews\My project\UnityEngine.UI.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\Drews\My project\Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for 'c:\Users\Drews\My project\UnityEditor.UI.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in 'c:\Users\Drews\My project'.
[info]: OmniSharp.Script.ScriptProjectSystem
Did not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\Drews\My project' on host
788.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\Drews\My project\UnityEngine.UI.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve
this, install the Developer Pack (SDK/Targeting Pack) for this framework version or
retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Users\Drews\My project\UnityEngine.UI.csproj'.
c:\Users\Drews\My project\UnityEngine.UI.csproj
C:\Program Files\dotnet\sdk\6.0.401\Microsoft.Common.CurrentVersion.targets(1220,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To
resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version
or retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\Drews\My project\Assembly-CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve
this, install the Developer Pack (SDK/Targeting Pack) for this framework version or
retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Users\Drews\My project\Assembly-CSharp.csproj'.
c:\Users\Drews\My project\Assembly-CSharp.csproj
C:\Program Files\dotnet\sdk\6.0.401\Microsoft.Common.CurrentVersion.targets(1220,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To
resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version
or retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: c:\Users\Drews\My project\UnityEditor.UI.csproj
[fail]: OmniSharp.MSBuild.ProjectLoader
The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To resolve
this, install the Developer Pack (SDK/Targeting Pack) for this framework version or
retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file 'c:\Users\Drews\My project\UnityEditor.UI.csproj'.
c:\Users\Drews\My project\UnityEditor.UI.csproj
C:\Program Files\dotnet\sdk\6.0.401\Microsoft.Common.CurrentVersion.targets(1220,5):
Error: The reference assemblies for .NETFramework,Version=v4.7.1 were not found. To
resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version
or retarget your application. You can download .NET Framework Developer Packs at
https://aka.ms/msbuild/developerpacks
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: c:\Users\Drews\My
project\UnityEngine.UI.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: c:\Users\Drews\My project\Assembly-
CSharp.csproj
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: c:\Users\Drews\My
project\UnityEditor.UI.csproj
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName =
c:\Users\Drews\My project\Assets\Scripts\Player.cs, Range = Range { Start = Point { Line
= 0, Column = 0 }, End = Point { Line = 23, Column = 0 } } }
[warn]: OmniSharp.Roslyn.CSharp.Services.InlayHints.InlayHintService
Inlay hints requested for document not in workspace Location { FileName =
c:\Users\Drews\My project\Assets\Scripts\Player.cs, Range = Range { Start = Point { Line
=
0, Column = 0 }, End = Point { Line = 23, Column = 0 } } }
此外,智能感知不起作用,所以我必須手動輸入內容。 我不夠理智或不夠聰明,無法嘗試修復它。 如果需要更多信息,我會提供。
我不知道為什么這還沒有回答,但為了盡可能簡單,unity 不使用最新版本的 .net 但它仍然會引導您到最新的鏈接,但它寫在它正在尋找的日志中版本 4.7.1 從這里下載我的兄弟(下載 devPack 然后重新啟動你的電腦) https://do.net.microsoft.com/en-us/download/do.net-framework.net471
您需要 Dot.net 開發包版本 4.7.1 (不是運行時版本),VScode 才能與 Unity 一起正常工作。
確保在安裝開發包時關閉 Vscode 和 Unity。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.