Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

BuildPipeline.BuildContentDirectory

Suggest a change

Success!

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.

Close

Submission failed

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

Close

Cancel

Declaration

public static BuildReport BuildContentDirectory(BuildContentDirectoryParameters buildParameters);

Parameters

Parameter Description
buildParameters The build settings to use for the build, such as paths, roots, options, and compression.

Returns

BuildReport The BuildReport that contains the results and details of the build.

Description

Builds a content directory (serialized assets and scenes plus a manifest) at a defined output path.

Use buildParameters to configure the build, including the root assets to include, the output path, and optional compression and build options. Each entry in BuildContentDirectoryParameters.rootAssetPaths must be a ScriptableObject. The build includes those root assets and everything they reference, such as assets referenced through LoadableObjectId, Loadable<T0>, and LoadableSceneId.

The method creates BuildContentDirectoryParameters.outputPath if it doesn't exist, normalizes path separators, and defaults BuildContentDirectoryParameters.name to the output folder name.

The build uses EditorUserBuildSettings.activeBuildTarget and the active subtarget configured for that target in the build settings. Select the intended platform in the Build Profile window or through command line arguments so that the active target is set to the desired setting prior to calling this method.

To load the built content, register the output directory with ContentLoadManager.RegisterContentDirectory.

Additional resources: BuildContentDirectoryParameters, ContentLoadManager

using UnityEditor;
using UnityEngine;

namespace BuildDocExamples { public class BuildPipeline_BuildContentDirectoryExample { [MenuItem("BuildDocExamples/Build/Build Content Directory")] public static void BuildContentDirectoryExample() { var parameters = new BuildContentDirectoryParameters { outputPath = "Builds/MyContentDirectory", rootAssetPaths = new[] { "Assets/MyRootAsset.asset" }, options = BuildContentOptions.None };

BuildPipeline.BuildContentDirectory(parameters); } } }