Unity learning record: error in new project / no code prompt in VS Code

When using VsCode to compile Unity, an error occurs when creating a new Unity project

This article is based on Unity2019.3.2f1 version, VsCode version 1.44.2

Today, when I opened Unity and created a new project for a long time, I found that Unity reported an error.
Report an errorIndexOutOfRangeException: Index was outside the bounds of the array.
VSCodeEditor.ProjectGeneration.b__25_0 (System.String asset) (at Library/PackageCache/[email protected]/Editor/ProjectGeneration/ProjectGeneration.cs:175)
Probably translated to mean that the index exceeds the boundary of the array. Then I created a new C# file and opened it with VsCode and found that the problem seemed to be quite serious. My UnityEditor.UI.csproj and other files are gone.
csproj is gone
VS Code also reminded me that I could not find the corresponding file, and writing code on VS Code after missing the .csproj file will not give a corresponding prompt.
Gone
So I started to find a solution online. There are many solutions on the Internet, and I found a very simple and efficient method.

Let me talk about the reason first

There are generally two reasons for this type of problem.

  1. There is a problem with the 1.14 version of the VS Code plugin in Unity, and the .csproj file will not be automatically generated
  2. VsCode will delete the .dll file after the upgrade and cause an error

Solution

Open Unity➡Window➡Package Manager, find the plug-in of VS Code and
Plug-in
upgrade it to version 1.2.0, then open Edit➡Preferences, find External Tools
preferences
and the page is different from before, click on the newly appeared Regenerate project filesregenerate project file, That's it.
Open VS Code again and you will find that the files are automatically generated.
carry out
Then the corresponding code hint will appear.

Guess you like

Origin blog.csdn.net/weixin_46149121/article/details/105701892