简体   繁体   English

如何将纯C ++代码与IL2CPP一起用于Unity编译为Windows应用程序?

[英]How to use pure C++ code with IL2CPP for Unity compilation into windows application?

I want to have a crossplatform application (including browser integration). 我想要一个跨平台的应用程序(包括浏览器集成)。 I have C++ library\\algorithms I want to use in form of sources (to make Unity compile it on each platform). 我有C ++库\\算法,希望以源代码形式使用(使Unity在每个平台上编译它)。 I know it could work if I use Mac or WebGL as primary build targets. 我知道如果将Mac或WebGL用作主要构建目标,则可以使用。 Yet I have windows as my primary user base. 但是,我以Windows为主要用户群。 So I want to use IL2CPP on windows to compile my C# and C++ code. 所以我想在Windows上使用IL2CPP来编译我的C#和C ++代码。

How to structure project and set IL2CPP to compile C++ files in unity on windows in order to create windows executable? 如何构建项目并设置IL2CPP以在Windows上统一编译C ​​++文件以便创建Windows可执行文件?

You can talk with C or C++ (and others depending on your target platforms) libraries using Native Plugins . 您可以使用Native Plugins与C或C ++(以及其他取决于目标平台的库)进行交谈。 It is even possible to use to call C++ function from a plugin using WebGL thanks to emscripten compilation. 借助emscripten编译,甚至可以使用WebGL 从插件调用C ++函数

Note that it has nothing to do with IL2CPP. 请注意,它与IL2CPP无关。 IL stands for Intermediate Language (IL), the low-level output from .NET compilers. IL代表中间语言(IL),这是.NET编译器的低级输出。 Your C++ code will be compiled directly to machine code/ASM code and will be called from within your script code. 您的C ++代码将直接编译为机器代码/ ASM代码,并将在您的脚本代码中调用。 Your script will either be running on the Mono virtual machine or using IL2CPP (depending on the platform). 您的脚本将在Mono虚拟机上运行,​​或使用IL2CPP(取决于平台)运行。

现在这是不可能的,因为Unity不支持IL2CPP作为Windows独立目标的脚本后端。

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

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