简体   繁体   English

Unity Api 兼容级别为 .NET Standard 2 但 Visual Studio 继续使用 .NET v4.7.1

[英]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版本。

  1. In the Unity editor, click the menu Edit -> Project Setting -> Player.在Unity编辑器中,点击菜单Edit -> Project Setting -> Player。

  2. 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.

相关问题 为什么 Autofac.Integration.WebApi.Owin 5.0.0 在 TargetFramework v4.7.1 上引用 System.Net.Http 4.2.0? - Why is Autofac.Integration.WebApi.Owin 5.0.0 referencing System.Net.Http 4.2.0 on TargetFramework v4.7.1? 找不到框架“.NETFramework,Version=v4.7.1”的参考程序集 - Reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found Visual Studio .net 标准库模板使用指令中断? - Visual Studio .net standard library template breaks using directive? Microsoft Visual Studio 2017安装程序项目启动条件检查不适用于.net 4.7.1 - Microsoft Visual Studio 2017 Installer Projects launch condition check not work for .net 4.7.1 C# 项目的目标是 NETFramework Version=v4.7.1,这台机器上没有安装 - The C# project is targeting NETFramework Version=v4.7.1, which is not installed on this machine Visual Studio扩展中的.Net Standard项目类型 - .Net Standard project type in Visual Studio extension 如何在 Visual Studio 中将 .NET Framework 更改为 .NET Standard/Core? - How to change .NET Framework to .NET Standard/Core in Visual Studio? 将Unity3d连接到4.0 .net Framework API Visual Studio程序 - Connecting Unity3d to a 4.0 .net framework API visual studio program Visual Studio 2019 - .NET 标准项目兼容性警告 - Visual Studio 2019 - .NET Standard Project compatibility warning Visual Studio 2017使用.net标准库时复制太多文件 - Visual Studio 2017 Copy too many files when using a .net standard library
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM