Linux IL2CPP 交叉编译器是一组 sysroot 和工具链包,允许您在任何独立平台上构建 Linux IL2CPP Players,而无需使用 Linux Unity 编辑器或依赖 Mono。
If you meet the prerequisites, Unity automatically installs these packages for you when you choose the Linux build target. If you want to opt out of this process and use your own sysroot and toolchain packages, go to Edit > Project Settings > Toolchain Management and disable the Install Toolchain package automatically checkbox. If you already have these installed, you also need to remove them from the package manager.
Warning: Setting additional IL2CPP arguments might affect your project compilation. For more information, see Handling IL2CPP additional arguments.
Unity 需要以下条件才能安装 IL2CPP 交叉编译器包:
Linux sysroot 包是一个目录,其中包含为 Linux 构建所需的所有头文件和库。
每个操作系统 (OS) 都有自己的构建系统,这些系统各不相同。如果您使用特定操作系统的头文件和库进行构建,则构建的 Player 可能无法在其他操作系统上运行。为了解决这个问题,Unity 提供了一个 sysroot 来构建,它适用于所有支持的 Linux 平台。
Unity 为 macOS、Windows 和 Linux 提供了工具链包。每个平台采用独特的方式针对 Linux 进行构建。
Linux 工具链包一组包含编译器和链接器的工具,Unity 需要使用这些工具从这些操作系统进行 Linux 构建。
确保您有足够的磁盘空间用于软件包的下载、解压缩和使用。
在极少数情况下,您无法确定是否有足够空间,可以定义一个 UNITY_SYSROOT_CACHE 环境变量并使用它来存储未压缩的 sysroots 和工具链包。环境变量是您在 Unity 之外设置的变量,可供 Unity 引用。在这种情况下,您设置了一个缓存,Unity 在解压缩 sysroot 和工具链包时可以引用该缓存。环境变量特定于您的操作系统,因此您需要遵循系统指南进行设置。
下表显示了每个工具链包的总磁盘空间要求。
工具链包 | 所需磁盘空间 |
---|---|
com.unity.toolchain.linux-x86_64 | 462MB |
com.unity.toolchain.macos-x86_64-linux-x86_64 | 2GB |
com.unity.toolchain.win-x86_64-linux-x86_64 | 2GB |
If you meet all the prerequisites on this page, you can build your project as a Linux Player. Unity automatically uses the Linux IL2CPP cross-compiler at build time.
要构建 Linux Player,请执行以下步骤:
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.