I've been using Unity3D these days and checked manuals about .NET system. But felt very confused.
In Unity3D Player Settings, there are two options called "scripting runtime version" and "api compatibility level".
When I set "scripting runtime version" to ".NET 3.5 Equivalent", I can choose "api compatibility level" between ".NET 2.0" and ".NET 2.0 Subset". But why these two option values are different? Shouldn't they refer to the same .NET version value? What does the word ".NET" in the two different options mean? Which .NET version is Unity3D actually using?
And, when I set "scripting runtime version" to ".NET 4.6 Equivalent", I can choose "api compatibility level" as ".NET4.6". But why these two option values are the same at this time?
On the other side, I found some manuals on Microsoft Websites introducing .NET system, and they say there is .NET Standard, .NET Framework, .NET Core and Mono. There isn't standalone ".NET" entity at all.
So, what does .NET version in "scripting runtime version" and "api compatibility level" of Unity Player Settings actually mean?
Facts:
There is no "scripting runtime version" option before Unity2017.1.0
.NET Framework has good backward compatibility, which means .NET 2.0 components are able to run on .NET 3.5 without break.
When we are talking about .NET version, it always refers to version of .NET Framework.
Unity3D is updating runtime to .NET 4.6.
Infer:
.NET Framework has good backward compatibility, so does mono.
Unity3D uses a mono as runtime, which is equivalent to .NET 3.5
Unity3D only uses .NET 2.0 features to compile but has a .NET 3.5 runtime to run on. That's why "api compatibility level" is ".NET 2.0" when "scripting runtime version" is ".NET 3.5"
Unity3D is updating to use .NET 4.6 features on .NET 4.6 runtime. That's why "api compatibility level" is ".NET 4.6" when "scripting runtime version" is ".NET 4.6"
Here is another relevant question: Why does Unity use .NET 2.0 when Mono supports .NET 3.5?
And a relevant thread: https://forum.unity.com/threads/to-linq-or-not-to-linq.223887/
Unity3D only uses . NET 2.0 features to compile but has a . NET 3.5 runtime to run on. That's why "api compatibility level" is ".
x equivalent scripting runtime, you can specify the Api Compatibility Level using the dropdown menu in the PlayerSettings (Edit > Project Settings > Player). There are two options: . NET Standard 2.0.
The default Scripting Runtime Version is . NET 4.6.
By default, most Unity projects should use the . NET Standard 2.0 profile.
What does .NET version in "scripting runtime version" and "api compatibility level" of Unity Player Settings actually mean?
API Compatibility Level:
Just an option given to you to specify how the compiler should compile the project. They are the-same .Net version. See below for what you get for each option.
.NET 2.0 Subset
.NET 2.0 is the opposite.
Scripting Runtime Version:
This is where you chose which .NET version you want to use. Changing this will let you use the select the .NET API and runt-time version.
So, selecting .NET 4.6 let you use the .Net 4.6 API to code your code and Unity will include .NET 4.6 runtime in your game. The-same thing applies to the .NET 3.5.
Wonder why they all have "Equivalent" as post fix? That's because some of the API's and features are either removed or stripped out in the Unity. You will notice this but this only applies to few amount of .NET API. Most of them are supported.
And, when I set "scripting runtime version" to ".NET 4.6 Equivalent", I can choose "api compatibility level" as ".NET4.6". But why these two option values are the same at this time???
Nope. That's not true. You only see both options in the "Scripting Runtime Version" option but you can't select ".NET 3.5" if "API Compatibility Level" is set to ".NET 4.6".
If you try this, Unity should restart then select ".NET 3.5" for "Scripting Runtime Version" and automatically change "API Compatibility Level" from ".NET 4.6" to ".NET 3.5".
So, if ".NET 4.6" as "API Compatibility Level", you must also select ".NET 4.6" as the "Scripting Runtime Version".
Which .NET version is Unity3D actually using?
The one you selected under the "Scripting Runtime Version" menu.
I wonder why I only have to select ".NET 2.0" or ".NET 2.0 Subset" for "api compatibility level" when setting "scripting runtime version" to ".NET 3.5". When "scripting runtime version" equals ".NET 3.5", I think "api compatibility level" should be ".NET 3.5" or ".NET 3.5 Subset". That is weird here in Unity. What went wrong here?
Licensing.
There was a licencing issue. Unity's company's only way to update the run-time was to pay a great amount of money to Xamarin since Xamirin made that mono run-time Unity is using and is under the LGPL. They didn't want to do that. I noticed they were able to update mono run-time after the partnered with Microsoft and joined the .NET Foundation last year.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With