BuildPipeline.BuildPlayer Manual     Reference     Scripting  
Scripting > Editor Classes > BuildPipeline

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


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. Must include any necessary file extensions, like .exe, .app, .unity3d or .wdgt.
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 (Unity Pro only).

Use this function to programatically create a build of your project.

// Building a web player unity3d file
["Assets/MyScene.unity"], "MyScene.unity3d",

When BuildOptions.BuildAdditionalStreamedScenes is used, the resulting file will not be a traditional player. The result will be a file that can be dynamically loaded in at runtime. In order to dynamically load one of these extra scenes in, download the file using the WWW class, and make sure to call WWW.assetBundle. You don't actually have to call AssetBundle.LoadAll(). As soon as you assigned WWW.assetBundle to a variable, from that point on, you can use regular Application.LoadLevel() and Application.LoadLevelAdditive() calls to load the level as you would usually do.

// Build a streamed unity3d file. This contain one scene that can be downloaded
// on demand and loaded once it's asset bundle has been loaded.
["Assets/DynamicallyLoadedScene.unity"], "DynamicallyLoadedScene.unity3d",
BuildTarget.WebPlayer, BuildOptions.BuildAdditionalStreamedScenes);