Unity3D - can I use .NET 4.5 assembly as external

2019-07-02 00:11发布

问题:

I want to use set of features, implemented in .NET Framework v4.5. Cause Unity3D works on Mono runtime(equivalent to .NET 3.5), i think to use .NET4.5 assemblies as external plugin.

Is it possible? If it possible, which runtime will be used for this libraries - Mono or assembly's target runtime (.NET 4.5 in my case)?

回答1:

As far as I know you can't because unity runs on mono. Have a look here http://docs.unity3d.com/410/Documentation/ScriptReference/MonoCompatibility.html

Basically, Unity goes upto .NET 3.5 or there about, with some features similar to c# 4.0 like optional parameters.

The main thing to keep in mind is that Unity3d is not using .NET 2.0 despite what you see in the build settings.

EDIT 2 :

I've seen somewhere that you definitely can't reference 4.5 assemblies directly. Cant' find the resource now.

In any case, I suppose it may be possible to make a C++ wrapper that would call 4.5 assemblies. The thing is even if you wrote a wrapper that worked this way, it would only work on windows machines. Basically due to the fact that mono isn't able to support them on any other platform. Again in theory.

DISCLAIMER : The mono support part is just an educated guess. I'm not 100 % on that.

EDIT : This is also a good read What are the correct version numbers for C#?