简体   繁体   English

在Unity 5中使用.NET 4.5代码

[英]Using .NET 4.5 code in Unity 5

I am working on a game using Unity3D version 5. The game should use strict business rules already programmed in a C# .NET4.5 engine. 我正在使用Unity3D版本5开发游戏。游戏应该使用已经在C#.NET4.5引擎中编程的严格业务规则。 Using Xamarin/Mono, we hope to make this usable on windows, android, others... 使用Xamarin / Mono,我们希望在Windows,Android,其他方面使其可用...

I tried building the engine into a dll and use it as a managed plugin in Unity. 我尝试将引擎构建到dll中,并将其用作Unity中的托管插件。 But Unity uses an old version of Mono to compile the whole game and refuses to use .NET 4.5 dlls. 但Unity使用旧版Mono来编译整个游戏并拒绝使用.NET 4.5 dll。

I really need to use this code, I looked into downgrading it to .NET 3.5 but it is not an acceptable solution given the work already done on the engine. 我真的需要使用这个代码,我考虑将它降级到.NET 3.5,但鉴于已经在引擎上完成的工作,它不是一个可接受的解决方案。

Concerning android, I think to use Xamarin to get native android code and use it as a native plugin in Unity. 关于android,我认为使用Xamarin获取原生的android代码并将其用作Unity中的本机插件。 Now I need a solution for Windows. 现在我需要Windows的解决方案。 I am looking into ways to use the C# code in C++ to make an unmanaged dll but I am struggling understanding which way is applicable here between COM interop, C++/CLI or other methods. 我正在研究如何使用C ++中的C#代码来创建一个非托管的DLL,但我很难理解COM interop,C ++ / CLI或其他方法之间适用的方法。

Does any one knows a way to include code from .NET 4.5 in Unity with no/little effort ? 有没有人知道如何在Unity中包含来自.NET 4.5的代码而没有/只需要很少的努力?

Looks like Unity is upgrading to 4.6+ and is available in beta now 看起来Unity正在升级到4.6+,现在可用于测试版

https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/ https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/

Using a visual studio plugin: unmanaged exports , I have been able to export the C# .NET 4.5 to an unmanaged/native dll which I can use in Unity Engine. 使用visual studio插件: 非托管导出 ,我已经能够将C#.NET 4.5导出到我可以在Unity Engine中使用的非托管/本机dll。 This forces to call only simple functions, but with little work, it was possible for me to wrap the core of my engine. 这迫使只调用简单的函数,但是只需要很少的工作,我就可以包装我的引擎的核心。

Short answer is no. 简短的回答是否定的。

Unity has ".NET 2.0/3.5 era functionality," according to an official blog post . 根据一篇官方博客文章 ,Unity拥有“.NET 2.0 / 3.5时代功能”。

According to the same post, a future version of Unity will be upgraded to "a modern version of .NET," with no timeline given for this major undertaking. 根据同一篇文章,Unity的未来版本将升级为“.NET的现代版本”,没有给出这项重大任务的时间表。

NOTE: This answer was written in response to the original version of the question, which was simply whether the .NET 4.5 library could be used directly in Unity. 注意:这个答案是为了回答问题的原始版本而编写的,这只是.NET 4.5库是否可以直接在Unity中使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM