简体   繁体   English

创建新项目后立即出现Unity错误

[英]Unity error immediately after creating a new Project

When creating a new 3D project in Unity (version 2019.3.3f1), I got an error in the Unity console without making any change or doing anything within Unity.在 Unity(版本 2019.3.3f1)中创建新的 3D 项目时,我在 Unity 控制台中出现错误,但没有在 Unity 中进行任何更改或执行任何操作。

The Error:错误:

IndexOutOfRangeException: Index was outside the bounds of the array. IndexOutOfRangeException: 索引超出数组范围。 VSCodeEditor.ProjectGeneration.b__25_0 (System.String asset) (at Library/PackageCache/com.unity.ide.vscode@1.1.4/Editor/ProjectGeneration/ProjectGeneration.cs:175) VSCodeEditor.ProjectGeneration.b__25_0(System.String 资产)(位于 Library/PackageCache/com.unity.ide.vscode@1.1.4/Editor/ProjectGeneration/ProjectGeneration.cs:175)

And the line of code supposedly wrong is from the file created w/ the Project called projectGeneration.cs.据称错误的代码行来自使用名为 projectGeneration.cs 的项目创建的文件。

var affectedNames = affectedFiles.Select(asset => m_AssemblyNameProvider.GetAssemblyNameFromScriptPath(asset)?.Split(new [] {".dll"}, StringSplitOptions.RemoveEmptyEntries)[0]);

Go into your Unity Package Manager and find the Visual Studio Code package.进入您的 Unity 包管理器并找到 Visual Studio Code 包。 Click 'see all versions'.单击“查看所有版本”。 Change the versions and try downgrading/updating (Sadly I don't know which version is compatible).更改版本并尝试降级/更新(遗憾的是我不知道哪个版本兼容)。 Restart Unity and it should be fixed.重新启动 Unity,它应该被修复。

I had the same problem.我有同样的问题。

The solution for me was to install .NET Framework 4.7.1 Developer pack from:- https://dotnet.microsoft.com/download/dotnet-framework/net471我的解决方案是从以下位置安装 .NET Framework 4.7.1 开发人员包:- https://dotnet.microsoft.com/download/dotnet-framework/net471

This is quite an old version, however this was the version requested by OmniSharp in the output window of VS Code.这是一个相当旧的版本,但这是 OmniSharp 在 VS Code 的输出窗口中请求的版本。

Note: This solution works with even the 1.2.0 version of the Visual Studio Code Editor package.注意:此解决方案甚至适用于 Visual Studio 代码编辑器包的 1.2.0 版本。

Downgrade visual studio code version to 1.1.3 to fix this error将 Visual Studio 代码版本降级到 1.1.3 以修复此错误

Open Unity, then go to: Window->Package Manager->Visual Studio Code 1.1.3打开Unity,然后转到: Window->Package Manager->Visual Studio Code 1.1.3

After that, just restart Unity and it will fix the error.之后,只需重新启动 Unity 即可修复错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM