[英]Unity Api Compability Level is .NET Standard 2 but Visual Studio keeps using .NET v4.7.1
I'm using unity 2020.1.1f1, I recently noticed I'm using all of .NET 4.x features, new syntax like Auto-property initializers as in public int Health { get; set; } = 100;
我正在使用 unity 2020.1.1f1,我最近注意到我正在使用 .NET 4.x 的所有功能,新语法,例如public int Health { get; set; } = 100;
public int Health { get; set; } = 100;
and so many others mentioned here以及这里提到的许多其他人
I get this for clrver command on Developer Command Prompt我在 Developer Command Prompt 上为 clrver 命令得到了这个
Microsoft (R) .NET CLR Version Tool Version 4.7.2558.0 Copyright (c) Microsoft Corporation. All rights reserved.
Versions installed on the machine: v2.0.50727 v4.0.30319
Unity Player Settings, API Compatibility Level is .NET Standard 2.0 Unity 播放器设置,API 兼容级别为 .NET 标准 2.0
I've changed Assembly-CSharp.csproj v4.7.1 to v2.0 but it discards my changes and goes back to 4.7.1我已将 Assembly-CSharp.csproj v4.7.1 更改为 v2.0,但它放弃了我的更改并返回到 4.7.1
I'm targeting mobile devices, I think .NET 2.0 is better for me but I don't know if whether Unity is actually using .NET 2 or .NET 4, since Unity Settings is set to use .NET Standard 2我的目标是移动设备,我认为 .NET 2.0 对我来说更好,但我不知道 Unity 是否实际使用 .NET 2 或 .NET 4,因为 Unity 设置设置为使用 .NET 标准 2
The first is to update the.NET version of VS: Project -> Properties.首先是更新.NET版本的VS:Project -> Properties。
Modify the .NET version used by the Unity project.修改Unity工程使用的.NET版本。
In the Unity editor, click the menu Edit -> Project Setting -> Player.在Unity编辑器中,点击菜单Edit -> Project Setting -> Player。
Select the corresponding .NET version in Scripting Runtime Version*. Select 脚本运行时版本*中对应的 .NET 版本。
reference link: https://docs.unity3d.com/Manual/do.netProfileSupport.html .参考链接: https://docs.unity3d.com/Manual/do.netProfileSupport.html 。
Close VS.关闭VS。 Check whether the Unity-related components are installed on the VS installer, and check it.检查VS安装器上是否安装了Unity相关组件,并检查。
At this time, please check whether the Visual Studio Editor exists in the Unity of the current project: Window → Package Manager.此时请检查当前项目的Unity中是否存在Visual Studio Editor:Window → Package Manager。
If it does not exist, switch Packages:Unity Registry in Package Manager, search for Visual Studio Editor, and click Install in the lower right corner.如果不存在,在Package Manager中切换Packages:Unity Registry,搜索Visual Studio Editor,点击右下角的Install。
Finally, Edit → Preferences... → External Tools, the selection box on the right side of the External Script Editor.最后,Edit → Preferences... → External Tools,External Script Editor右侧的选择框。 Check the currently installed version of VS.检查当前安装的 VS 版本。
Reference document: https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/troubleshooting/troubleshooting-and-known-issues-visual-studio-tools-for-unity#incompatible-project-in-visual-studio .参考文档: https://learn.microsoft.com/en-us/visualstudio/gamedev/unity/troubleshooting/troubleshooting-and-known-issues-visual-studio-tools-for-unity#incompatible-project-in-visual -工作室。
Hope it helps you.希望对你有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.