I'm trying to build one of the simple EventBus libraries from Github and import them into Unity. Here are the libs:

TinyMessenger and RedBus

It's that simple - I take the source code, build it through the VS2015 and place the .dll into the Assets/Plugins folder.

Then, I have no way to use the lib's namespace (Unity doesn't read the file).

Both of these libraries are written in NET 3 or 4 and this is the failure's reason. I've recompiled the second one (removed the System.Linq code, changed the project's version) to NET 2.0 and it worked, but that's not the point. I need the first library and it ain't easy to rewrite the entire 4.0 code to 2.0 without Linq.

As I remember, you can use System.Linq in Unity (at least, I did it once). This means that Unity uses some kind of trickery/magic, as always.

What's the problem here? Is there any way to get this working?

  • \$\begingroup\$ It should be possible instruct VS compiler to output for older versions of .NET. How to do that exactly I am not sure, but can give you a lead - the C# 6 project which did that for Unity projects. Adapting the solution for generic libraries should be possible as well. \$\endgroup\$ – wondra Aug 10 '17 at 16:51
  • \$\begingroup\$ Yes, it is possible through project settings. But the project is coded for a NET > 2 it uses Linq everywhere. \$\endgroup\$ – Jacob Aug 10 '17 at 16:52
  • \$\begingroup\$ Well... it is exactly what the linked project does - allow you using the C# 6 features throughout the project and then compile it into .NET 2.0 compatible CLR The problem I see is if the said libraries depend on other libraries that could not be loaded. "Microsoft and Mono compilers can compile C# 5/6/7 code for CLR 2.0 if you explicitly ask them to do so." explicitly stated in second sentence of the projects description. \$\endgroup\$ – wondra Aug 10 '17 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.