Created
December 16, 2015 16:13
-
-
Save tsubaki/0d961ecfaf1c0de314cb to your computer and use it in GitHub Desktop.
AssetBundleをダイアログを指定して出力する。依存関係は知らない
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using UnityEditor; | |
using System.IO; | |
using System.Collections.Generic; | |
using System.Linq; | |
public class ExportAssetbundle { | |
[MenuItem("Assets/ExportAssetBundle")] | |
static void ExportTargetAssets() | |
{ | |
if (Selection.objects.Length == 0) | |
return; | |
// AssetBundleを出力するパスを指定 | |
// ここで指定した名前はAssetBundle名にもなる | |
var path =EditorUtility.SaveFilePanel ("save assetbbundle", "Assets", "sample", null); | |
if (string.IsNullOrEmpty (path)) | |
return; | |
// 選択中のオブジェクトからファイルを取得 | |
var includeAssetpath = Selection.objects | |
.Where (c => string.IsNullOrEmpty (AssetDatabase.GetAssetPath (c)) == false) | |
.Select (c => AssetDatabase.GetAssetPath (c)) | |
.ToArray (); | |
// AssetBundleに含めるアセットとAssetBundle名を指定 | |
AssetBundleBuild build = new AssetBundleBuild (); | |
build.assetBundleName = Path.GetFileName (path); | |
build.assetNames = includeAssetpath; | |
// AssetBundleを出力 | |
BuildPipeline.BuildAssetBundles ( | |
Path.GetDirectoryName (path), | |
new AssetBundleBuild[]{ build }, | |
BuildAssetBundleOptions.ChunkBasedCompression); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment