[英]Can I use IL2CPP (Intermediate Language To C++) for non-Unity applications?
IL2CPP.exe is a Unity utility for converting C# IL code to C++. IL2CPP.exe是一个 Unity 实用程序,用于将 C# IL 代码转换为 C++。 My question is: can this executable be used outside of the Unity game-development environment as a general-purpose tool for converting any .NET application (not just games) to a high-performance native executable?我的问题是:这个可执行文件可以在 Unity 游戏开发环境之外用作通用工具,用于将任何.NET 应用程序(不仅仅是游戏)转换为高性能本机可执行文件吗?
Although I do know some C++, It would certainly be nice to be able write all kinds of programs in a language I am comfortable and fluent with (C#)......whether they be audio/video/music-production DAWs or OS-level security/forensics tools or machine-learning platforms or anything else that's resource-intensive.......and know that they will run as efficiently as an app written in straight C++.虽然我确实知道一些C++,但能够用我熟悉和流利的语言(C#)编写各种程序肯定会很好......无论它们是音频/视频/音乐制作 DAW 还是操作系统级安全/取证工具或机器学习平台或任何其他资源密集型......并且知道它们将像直接用 C++ 编写的应用程序一样高效地运行。
IL2CPP is tightly connected to the Unity environment and it's not possible to use it outside of Unity. IL2CPP 与 Unity 环境紧密相连,无法在 Unity 之外使用它。 You would need to write your own converter(?) to do such a thing.您需要编写自己的转换器(?)来做这样的事情。
IL2CPP doesn't do any magic in terms of performance improvement. IL2CPP 在性能改进方面没有任何魔力。 Comparing C++ with C# with IL2CPP code should give (almost - more below) no performance benefit.将 C++ 与 C# 与 IL2CPP 代码进行比较应该没有性能优势(几乎 - 更多如下)。
IL2CPP is performant compared to C# code written for Unity specifically for few reasons that have nothing to do with C++.与为 Unity 编写的 C# 代码相比,IL2CPP 的性能更高,特别是出于与 C++ 无关的几个原因。
Why Unity is unique and needs IL2CPP:为什么 Unity 是独一无二的并且需要 IL2CPP:
So why IL2CPP?那么为什么是 IL2CPP 呢?
Is it worth converting other C# to C++?是否值得将其他 C# 转换为 C++?
No!不! Compare any arbitrary, optimized C# code that was precompiled by AOT to (modern) C++.将 AOT 预编译的任意优化 C# 代码与(现代)C++ 进行比较。 You should get the same performance.您应该获得相同的性能。 Identical I would say.我会说是一样的。
C# is compiled to IL (Intermediate Language) which as the name suggests is Intermediate. C# 编译为 IL(中间语言),顾名思义就是中间语言。 It's converted in runtime to Native Binary code (only when needed), that is what C++ is compiled into.它在运行时转换为本机二进制代码(仅在需要时),这就是 C++ 编译成的。 You can force this conversion by skipping IL generation by running Ahead of Time compilation (AOT).您可以通过运行 Ahead of Time 编译 (AOT) 跳过 IL 生成来强制进行此转换。
The ONLY thing that your C# code will be less performant is when you are abusing GC's ability to clean up after you.您的 C# 代码的唯一性能会降低是当您滥用 GC 的清理能力时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.