You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity设置.NET Standard 2.0,但Visual Studio始终使用.NET 4.7.1的问题

Unity .NET版本兼容性疑问

当前环境与操作情况

  • 所用Unity版本:2020.1.1f1
  • 代码中已在使用.NET 4.x特性,例如自动属性初始化器:public int Health { get; set; } = 100;
  • 本地执行clrver命令查看已安装的.NET CLR版本,输出如下:

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兼容性级别设置为.NET Standard 2.0;曾手动修改Assembly-CSharp.csproj的目标框架版本从4.7.1改为2.0,但修改会被Unity自动还原
  • 开发目标平台为移动设备,原本认为.NET 2.0更适配,但不确定Unity实际运行时采用的是.NET 2还是.NET 4,因为当前设置的是.NET Standard 2.0

核心疑问

Unity设置的API兼容性级别是.NET Standard 2.0时,实际运行时到底基于.NET 2还是.NET 4?为什么我能正常使用.NET 4.x的特性?

Unity Player Settings中API兼容性级别设置

内容的提问来源于stack exchange,提问作者Alireza Jamali

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 20:30:38