4

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)?

lewis
  • 482
  • 2
  • 10
  • 22

1 Answers1

2

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#?

Community
  • 1
  • 1
Alex
  • 1,110
  • 8
  • 15
  • I know about Unity3D's default runtime (Mono). I'm talking about using .NET 4.5 assemblies as **external** library, according to Unity documentation: "_Unity has extensive support for Plugins, which are libraries of native code written in C, C++, Objective-C, etc. Plugins allow your game code (written in Javascript, C# or Boo) to call functions from these libraries. This feature allows Unity to integrate with middleware libraries or existing C/C++ game code._" – lewis Dec 21 '13 at 11:11
  • @lewis that was addressed in his explanation. You can't reference a managed library that requires a higher version of. Net support than is installed. – Frazell Thomas Dec 21 '13 at 14:48
  • @Frazell, my Unity3D uses Mono runtime, but .NET 4.5 also installed on my desktop. – lewis Dec 22 '13 at 11:27
  • 1
    @lewis thats not the point. It doesn't matter what you have installed. Unity's runtime can't support that. – Alex Dec 22 '13 at 15:15
  • 1
    It depends on what the target machine is and whether or not the .NET 4.5 CLR can even be installed. If the target machine is an IPhone or an Android phone, then I suspect not. If the target machines consist of just windows OS on desktops or laptops, then I don't see a problem using a plugin to access the .NET 4.5 CLR. – Bob Bryan Jan 14 '15 at 03:01
  • 1
    Presumably if you write your plugin in C# and build it to a DLL, then Unity will be loading the DLL and attempt to resolve it against Mono. But perhaps (as @Alex said in his answer) you could build a bridge plugin in C++ which initialises the platform's .NET runtime, and loads the .NET DLL. That would only work on Windows, though. – Sam Jan 17 '16 at 00:39