アセットバンドルを作成します (Unity Pro のみ)
pathName のコレクションを含む圧縮した unity3d ファイルを作成します。アセットバンドルはプロジェクトフォルダにある任意のアセットを含めることが出来ます。
アセットバンドル化できるのは、任意の型のリソースデータ、フルセットアップされたプレハブ、テクスチャ、メッシュ、アニメーション、およびプロジェクトウィンドウで表示される任意の型のアセットであり、これらをストリーミングすることが出来ます。
pathName により AssetBundle.mainAsset を使用して簡便に取得したいオブジェクトを指定できます。
圧縮されたアセットバンドル ファイルは pathName に保存されます。
/options/ により自動的に依存関係を含めたり、ただ参照されたオブジェクトのみだけでなく常に完全なアセットを含めることが出来ます。
全てのパスはプロジェクトフォルダに対する相対パス指定になります: "Assets/MyTextures/hello.png"。オプションである crc 出力引数により生成されたアセットバンドルに対して CRC チェックサムを取得できます。これは WWW.LoadFromCacheOrDownload を使用してアセットバンドルをダウンロードするときにコンテンツを確認できます。
スタンドアローンまたはウェブプレイヤー向けのターゲットでビルドされたアセットバンドルは
モバイルプラットフォーム向けにビルドされたアプリケーションではロード出来ませんし、その逆もまた然りです。
さらにアセットバンドルは iOS と Android プラットフォームで互換性がありません。
関数の戻り値は boolean 型であり、ビルドが成功した場合は true、そうでなければ false です。
See Also: AssetBundle クラス, WWW.assetBundle.
// 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,
BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);
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);
}
}
}