Legacy Documentation: Version 5.4
  • C#
  • JS

Script language

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


Suggest a change


Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.


Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.



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


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.

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/BuildPlayer")
static function MyBuild(){
	var levels : String[] = ["Assets/Scene1.unity", "Assets/Scene2.unity"];
	BuildPipeline.BuildPlayer( levels, "PlayerBuild", 
			BuildTarget.StandaloneWindows, BuildOptions.None);