Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

BuildPipeline.BuildPlayer

static function BuildPlayer(levels: string[], locationPathName: string, target: BuildTarget, options: BuildOptions): string;
static string BuildPlayer(string[] levels, string locationPathName, BuildTarget target, BuildOptions options);
static def BuildPlayer(levels as string[], locationPathName as string, target as BuildTarget, options as BuildOptions) as string

Parameters

levelsThe 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).
locationPathNameThe path where the application will be built.
targetThe BuildTarget to build.
optionsAdditional BuildOptions, like whether to run the built player.

Returns

string An error message if an error occurred.

Description

Builds a player (Unity Pro only).

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.

	// Build a folder containing unity3d file and html file
	@MenuItem ("Build/BuildWebplayer")
	static function MyBuild(){
		var levels : String[] = ["Assets/Scene1.unity", "Assets/Scene2.unity"];
		BuildPipeline.BuildPlayer( levels, "WebPlayerBuild", 
					   BuildTarget.WebPlayer, BuildOptions.None); 
	}