Version: 1.3
语言 : 中文
Troubleshooting the ArmLinux platform issues
ArmLinux Dedicated Server

Build Unity projects from the Command Line

要在命令行界面 (CLI) 上为 Arm Linux 系统构建 Unity 项目,您必须在构建主机上安装 Unity 编辑器。构建主机可以是 Linux、Windows 或 macOS 机器。

下面的示例使用了 Linux 版本的可执行文件(Tuanjie),但您可以将其替换为您首选的构建主机操作系统的等效可执行文件。

Command line arguments

要指示 Unity 以 CLI 模式启动并为 Arm Linux 构建位于 <path-to-unity-project-root> 的项目,请运行以下命令: Tuanjie.exe -quit -batchmode -nographics -buildtarget ArmLinux -executeMethod Builder.Build -projectPath <path-to-unity-project-root> 构建过程还会调用函数 Builder.Build 以继续进行构建设置过程。

Build script

您可以将示例构建脚本放置在项目的 Assets/Editor/ 目录下,以便从命令行构建项目。使用 -executeMethod 选项调用此类的 Build() 方法,该方法设置构建选项并触发构建。

#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.Build.Content;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class Builder
{
    private static void BuildArmLinux()
    {
        // Setup build options (e.g. scenes, build output location)
        var options = new BuildPlayerOptions
        {
            // Change to scenes from your project
            scenes = new[]
            {
                "Assets/<your-scene-path>",
            },
            // Change to location the output should go
            locationPathName = <your-path-to-build-armlinux>,
            options =  BuildOptions.CleanBuildCache | BuildOptions.StrictMode,
            target = BuildTarget.ArmLinux
        };

        var report = BuildPipeline.BuildPlayer(options);

        if (report.summary.result == BuildResult.Succeeded)
        {
            Debug.Log($"Build successful - Build written to {options.locationPathName}");
        }
        else if (report.summary.result == BuildResult.Failed)
        {
            Debug.LogError($"Build failed");
        }
    }

    // This function will be called from the build process
    public static void Build()
    {
        BuildArmLinux();
    }
}
#endif
Troubleshooting the ArmLinux platform issues
ArmLinux Dedicated Server