buildPlayerOptions | Provide various options to control the behavior of BuildPipeline.BuildPlayer. |
string A BuildReport giving build process information.
Builds a player.
Use this function to programatically create a build of your project.
Note that any references to GameObjects acquired in the editor script before
the BuildPlayer call will be invalid after it and will need to be reacquired.
no example available in JavaScript
using UnityEditor; using UnityEngine; using UnityEditor.Build.Reporting;
// Output the build size or a failure depending on BuildPlayer.
public class BuildPlayerExample : MonoBehaviour { [MenuItem("Build/Build iOS")] public static void MyBuild() { BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions(); buildPlayerOptions.scenes = new[] { "Assets/Scene1.unity", "Assets/Scene2.unity" }; buildPlayerOptions.locationPathName = "iOSBuild"; buildPlayerOptions.target = BuildTarget.iOS; buildPlayerOptions.options = BuildOptions.None;
BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions); BuildSummary summary = report.summary;
if (summary.result == BuildResult.Succeeded) { Debug.Log("Build succeeded: " + summary.totalSize + " bytes"); }
if (summary.result == BuildResult.Failed) { Debug.Log("Build failed"); } } }
levels | The scenes to be included in the build. If empty, the currently open scene will be built. Paths are relative to the project folder (Assets/MyLevels/MyScene.unity). |
locationPathName | The path where the application will be built. |
target | The BuildTarget to build. |
options | Additional BuildOptions, like whether to run the built player. |
string An error message if an error occurred.
Builds a player. These overloads are still supported, but will be replaced. Please use BuildPlayer (BuildPlayerOptions buildPlayerOptions) instead.