.Net Standard 2.1 vs .Net Framework with Unity 2021.2 versions?

Since recent editor versions, in Player settings there is now Player > Other Settings > Configuration > Api Compatibility Level* with no real explanation in the editor or the docs what the difference between .NET Standard 2.1 and .NET Framework is for projects?

Just looking for a black-and-white answer to this if anyone has any tips?

See the "API Compatibility Level" section in the documentation.

All i get is:

Sorry… that page seems to be missing!

9 Likes
4 Likes

Thanks for the link, but my fundamental question about the difference between the two settings remains unanswered (already made a ducumentation improvement request):

Especially the “Cross-platform compatibility” section is very vague! While it states, that we should use .NET Standard for cross-platform development, the next few sentences make it sound like it’s a bad idea:

  • some platforms don’t fully support the .NET Standard
  • .NET Framework profile includes all APIs in the .NET Standard profile
  • [.NET Framework includes] additional APIs, some of which might work on few or no platforms.

When toggling the switch on an existing project (from Framework → Standard), I’d like to know if I might break some features somewhere. Will I get compiler warnings for unsupported features or will they just silently malfunction or crash in builds?

3 Likes

What it’s trying to say is that there is stuff in .NET Standard that will not work on all platforms (such as System.Reflection.Emit on IL2CPP or threads on WebGL). .NET Framework just adds more stuff that is more hit & miss. So if you stick with .NET Standard, you are less likely to run into things that don’t work.

You will get compiler errors. That setting only affects how your scripts are compiled.

2 Likes

Thanks for the clarification! If I’ll get compiler errors for missing features, then I’m reassured to just keep the “toggle” flipped.

2 Likes

You definitely do not get a compiler error for Thread not working on WebGL so I would be skeptical about other features as well

1 Like