Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

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

Obsolete
BuildAssetBundle has been made obsolete. Please use the new AssetBundle build system introduced in 5.0 and check BuildAssetBundles documentation for details.

BuildPipeline.BuildAssetBundle

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

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.

Close

Cancel

マニュアルに切り替える
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName);
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string, out crc: uint, assetBundleOptions: BuildAssetBundleOptions): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, out uint crc, BuildAssetBundleOptions assetBundleOptions);
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string, assetBundleOptions: BuildAssetBundleOptions): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, BuildAssetBundleOptions assetBundleOptions);
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string, out crc: uint): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, out uint crc);
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string, assetBundleOptions: BuildAssetBundleOptions, targetPlatform: BuildTarget): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform);
public static function BuildAssetBundle(mainAsset: Object, assets: Object[], pathName: string, out crc: uint, assetBundleOptions: BuildAssetBundleOptions, targetPlatform: BuildTarget): bool;
public static bool BuildAssetBundle(Object mainAsset, Object[] assets, string pathName, out uint crc, BuildAssetBundleOptions assetBundleOptions, BuildTarget targetPlatform);

Parameters

mainAsset AssetBundle.mainAsset を使用して簡単に取得したいオブジェクトを指定することができます。
assets バンドルに書き込むアセットの配列
pathName 圧縮したアセットバンドルを書き込むファイル名 (filename)
assetBundleOptions 自動的に依存関係を含めたり、ただ参照されたオブジェクトのみだけでなく常に関係するすべてのアセットを含める設定ができます。
targetPlatform 作成されたバンドルが使用されるプラットフォーム
crc オプションの crc 出力パラメーターは、生成されたアセットバンドルの CRC チェックサムを取得するためにを使用されます。チェックサムは、WWW.LoadFromCacheOrDownload を使ってアセットバンドルをダウンロードするときにコンテンツを検証するために使用されます。

Description

アセットバンドルをビルドします

Creates a compressed unity3d file that contains a collection of assets. AssetBundles can contain any asset found in the project folder. This lets you stream resource data of any type, fully setup prefabs, textures, meshes, animations, any type of asset shown in the project window.
All paths are relative to the project folder. Like: "Assets / MyTextures / hello.png".


スタンドアロンや Web Player 向けのターゲットでビルドされたアセットバンドルは モバイルプラットフォーム向けにビルドされたアプリケーションでは読み込めませんし、その逆もまた然りです。 さらにアセットバンドルは iOS と Android プラットフォームで互換性がありません。

関数の戻り値は boolean 型であり、ビルドが成功した場合は true、そうでなければ false です。

no example available in JavaScript
// C# Example
// Builds an asset bundle from the selected objects in the project view.
// Once compiled go to "Menu" -> "Assets" and select one of the choices
// to build the Asset Bundle
	
using UnityEngine;
using UnityEditor;

public class ExportAssetBundles { [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")] static void ExportResource () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets); BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, 0); Selection.objects = selection; } } [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] static void ExportResourceNoTrack () { // Bring up save panel string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d"); if (path.Length != 0) { // Build the resource file from the active selection. BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path); } } }

関連項目: AssetBundle クラス、WWW.assetBundle.