To build a Unity project for the Embedded Linux system on the command line interface (CLI), you must have the Unity Editor installed on the build host. The build host can be a Linux, Windows, or macOS machine.
The following example uses the Linux variant of the executable (Unity
), but you can replace it with an equivalent executable for your preferred build host’s operating system.
To instruct Unity to start in CLI mode and build the project at <path-to-unity-project-root>
for Embedded Linux, run the following command:
Unity -quit -batchmode -nographics -buildTarget EmbeddedLinux -executeMethod Builder.Build -projectPath <path-to-unity-project-root>
The build process also calls the function Builder.Build
to continue with the build setup process.
You can put the example build script Assets/Editor/
for the project to be built from the command line. Use the -executeMethod
option to call the Build()
method of this class, which sets up the build options and triggers the build.
For more information, refer to the BuildPipeline.BuildPlayer
API documentation.
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
public class Builder
{
private static void BuildEmbeddedLinux(EmbeddedLinuxArchitecture architecture)
{
// Set architecture in BuildSettings
EditorUserBuildSettings.selectedEmbeddedLinuxArchitecture = architecture;
// Setup build options (e.g. scenes, build output location)
var options = new BuildPlayerOptions
{
// Change to scenes from your project
scenes = new[]
{
"Assets/Scenes/SampleScene.unity",
},
// Change to location the output should go
locationPathName = "../EmbeddedLinuxPlayer/",
options = BuildOptions.CleanBuildCache | BuildOptions.StrictMode,
target = BuildTarget.EmbeddedLinux
};
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()
{
// Build EmbeddedLinux ARM64 Unity player
BuildEmbeddedLinux(EmbeddedLinuxArchitecture.Arm64);
}
}
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.