VSCode编写Unity脚本时无代码提示

使用VSCode编写Unity脚本时,发现没有代码提示,我使用的版本是Unity2021。

1.检查一下如下配置:Edit->Preferences->External Tools,External Script Editor 选择 Visual Studio Code,并且勾选上 Embedded packages 与 Local packages

如图:

2.已安装.NET SDK 6.0.402,VSCode已安装C#插件 

3.在Unity中双击打开C#脚本,此时查看VSCode的输出信息,如果有类似提示:

The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

在官网下载提示中的版本 .NET Framework4.7.1(地址:.NET SDKs downloads for Visual Studio)并且安装。再次在Unity中双击打开C#脚本,此时就有代码提示了。

github issues:

New Unity 2018.3 and OmniSharp in VS Code error. · Issue #115 · Unity-Technologies/vscode-unity-debug · GitHub

如果是在使用新的Unity版本或者引用新的工具库时,出现编译器不提示的情况,可以使用如下方法:点击上图中 Edit->Preferences->External Tools 的 “Regenerate project files” 按钮刷新项目文件夹中的 .csproj 和 .sln 文件。参考链接Unity使用VS Code编辑时,代码补全提示不全、误纠错的解决记录 - 哔哩哔哩 (bilibili.com)

猜你喜欢

转载自blog.csdn.net/fangling86/article/details/127775272
今日推荐