在 Unity 5 中使用 .NET 4.5 代码 [英] Using .NET 4.5 code in Unity 5

查看:54
本文介绍了在 Unity 5 中使用 .NET 4.5 代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款使用 Unity3D 版本 5 的游戏.该游戏应使用已在 C# .NET4.5 引擎中编程的严格业务规则.使用 Xamarin/Mono,我们希望它可以在 windows、android 和其他平台上使用...

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. Using Xamarin/Mono, we hope to make this usable on windows, android, others...

我尝试将引擎构建到 dll 中,并将其用作 Unity 中的托管插件.但是 Unity 使用旧版本的 Mono 来编译整个游戏,并且拒绝使用 .NET 4.5 dll.

I tried building the engine into a dll and use it as a managed plugin in Unity. But Unity uses an old version of Mono to compile the whole game and refuses to use .NET 4.5 dlls.

我真的需要使用这段代码,我考虑将其降级到 .NET 3.5,但鉴于引擎上已经完成的工作,这不是一个可接受的解决方案.

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.

关于android,我想用Xamarin来获取android原生代码,作为Unity中的原生插件使用.现在我需要一个适用于 Windows 的解决方案.我正在寻找在 C++ 中使用 C# 代码来制作非托管 dll 的方法,但我正在努力理解哪种方法适用于 COM 互操作、C++/CLI 或其他方法.

Concerning android, I think to use Xamarin to get native android code and use it as a native plugin in Unity. Now I need a solution for 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.

有没有人知道一种无需/很少努力就可以在 Unity 中包含来自 .NET 4.5 的代码的方法?

Does any one knows a way to include code from .NET 4.5 in Unity with no/little effort ?

推荐答案

使用 Visual Studio 插件:unmanaged导出,我已经能够将 C# .NET 4.5 导出到我可以在 Unity 引擎中使用的非托管/本机 dll.这迫使我只能调用简单的函数,但只需很少的工作,我就可以包装我的引擎的核心.

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. This forces to call only simple functions, but with little work, it was possible for me to wrap the core of my engine.

这篇关于在 Unity 5 中使用 .NET 4.5 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆